Problem
Custom facing problem:
"I'm trying to import android.support.v4.app.NotificationCompat class in my Appcelerator Android Module project.
To do this I have added jar 'support-compat-24.2.0.jar' in the lib folder. This has resolved all the import errors in the module."
Reproduce
1. Attached test Module customer created.
2. Simply import and require it into a default app.
Like:
var testmodule = require('com.abc.mcoe.testmodule');
3. Run the app. Will get following error.
Error
[ERROR] : Failed to run dexer:
[ERROR] :
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/internal/view/SupportSubMenu;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/internal/view/SupportMenu;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/internal/view/SupportMenuItem;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/NotificationManagerCompat;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/NotificationCompat$Style;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/NotificationCompat$NotificationCompatImplJellybean;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ShareCompat$ShareCompatImplJB;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/NotificationCompat$Action$1;
[ERROR] : Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/NotificationCompat$Builder;
[ERROR] :
[ERROR] : UNEXPECTED TOP-LEVEL EXCEPTION:
[ERROR] : java.lang.RuntimeException: Translation has been interrupted
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
[ERROR] : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
[ERROR] : at com.android.dx.command.dexer.Main.run(Main.java:277)
[ERROR] : at com.android.dx.command.dexer.Main.main(Main.java:245)
[ERROR] : at com.android.dx.command.Main.main(Main.java:106)
[ERROR] : Caused by: java.lang.InterruptedException: Too many errors
[ERROR] : at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
[ERROR] : ... 4 more
[~sliang] Upgrade to 6.0.0, remove
support-compat-24.2.0.jar
from your libs folder and runappc run -p android --build-only
in theandroid
directory of your module project.android-support-v4.jar
should already be included forandroid.support.v4.app.NotificationCompat
Let me know if that solves the issue.I compiled the testmodule using 6.0.1.GA without the included 'support-compat-24.2.0.jar' and imported it into a test project (also compiled with 6.0.1.GA).
The app runs fine and does not crash.
[~gmathews]: The problem here is if in the module we import the below statement (customer wants to use the library in module) and to resolve the reference we would have to add the 'support-compat-24.2.0.jar' in /android/lib directory in module. Module packaging works perfectly fine. Now we import the module in app test project with same code you ran above, then building the app project would throw the error messages as below.
Import statement in module:
import android.support.v4.app.NotificationCompat;Error messages
[~nmishra], as Gary already pointed out, you do not need to explicitly add the Android Support Library to the module to use it. I tested it with both CLI and Studio and the build works just fine with
import android.support.v4.app.NotificationCompat;
. To remove the warning in Appcelerator Studio that the import cannot be resolved you can do the following: 1. Right-click the module project (root folder) and select *Properties* to open the project's properties dialog. 2. In the left pane, select *Java Build Path*. 3. In the right pane, click the *Libraries* tab. 4. Click the *Add External JARs...* button to open the JAR Selection dialog. 5. Navigate to~/Library/Application Support/Titanium/mobilesdk/osx/6.0.1.GA/android
folder and select theandroid-support-v4
JAR. 6. Click Open. The JAR should be added to the JARs list. 7. Click OK to dismiss the dialog. If the issue still persists, please provide detailed steps to reproduce it.[~jvennemann] : Thanks much. It really worked like charm. We just could not find what was the conflicting jar from sdk.