adjust / cordova_sdk

This is the Cordova SDK of
http://www.adjust.com
MIT License
37 stars 43 forks source link

Android build not working with adjust v4.0.0 #21

Closed zwacky closed 9 years ago

zwacky commented 9 years ago

Hey guys I removed the old adjust@3.4.1 plugin and added the v4.0.0 and get the following error:

:dexArmv7Debug
>> 
>> 
>> UNEXPECTED TOP-LEVEL EXCEPTION:
>> 
>> 
>> com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
>> 
>> 
>>  at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
>> 
>> 
>>  at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
>> 
>> 
>>  at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
>> 
>> 
>>  at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
>> 
>> 
>>  at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
>> 
>> 
>>  at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
>> 
>> 
>>  at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
>> 
>> 
>>  at com.android.dx.command.dexer.Main.run(Main.java:246)
>> 
>> 
>>  at com.android.dx.command.dexer.Main.main(Main.java:215)
>> 
>> 
>>  at com.android.dx.command.Main.main(Main.java:106)
>> 
>> 
>> 
>> 

FAILED

>> 
>> 
>> FAILURE: 
>> Build failed with an exception.
>> 
>> 
>> 
>> * What went wrong:
>> 
>> Execution failed for task ':dexArmv7Debug'.
>> 
>> > 
>> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
>> 
>>      /Users/zwacky/Library/Android/sdk/build-tools/22.0.1/dx --dex --no-optimize --output /Users/zwacky/data/mc-webapp/mobile/platforms/android/build/intermediates/dex/armv7/debug --input-list=/Users/zwacky/data/mc-webapp/mobile/platforms/android/build/intermediates/tmp/dex/armv7/debug/inputList.txt
>> 
>>   Error Code:
>> 
>>      2
>> 
>>   Output:
>> 
>>      
>> 
>>      UNEXPECTED TOP-LEVEL EXCEPTION:
>> 
>>      com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
>> 
>>          at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
>> 
>>          at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
>> 
>>          at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
>> 
>>          at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
>> 
>>          at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
>> 
>>          at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
>> 
>>          at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
>> 
>>          at com.android.dx.command.dexer.Main.run(Main.java:246)
>> 
>>          at com.android.dx.command.dexer.Main.main(Main.java:215)
>> 
>>          at com.android.dx.command.Main.main(Main.java:106)
>> 
>>      
>> 
>> 
>> 
>> 
>> 
>> * Try:
>> 
>> Run with 
>> --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
>> 

BUILD FAILED

I noticed the new adjust_sdk.jar. v3.4.1 works without any problems but I really need your v4.0.0 - great stuff btw!

uerceg commented 9 years ago

@zwacky Did you read our migrate guide? https://github.com/adjust/cordova_sdk/blob/master/doc/migrate.md

It would be really important to run our uninstall script in order to properly remove all old v3.x.x files and then install v4.0.0 of our plugin.

Give it a try and let me know if it works.

zwacky commented 9 years ago

thanks for pointing out the migration guide (mainly removed the hook file), but it still doesn't compile with the same error. :(

i'm using ionic@1.6.1

list of the plugins (downgraded to 3.4.1 again):

com.adjust.sdk 3.4.1 "Adjust"
com.google.playservices 19.0.0 "Google Play Services for Android"
com.ionic.keyboard 1.0.4 "Keyboard"
com.phonegap.plugins.facebookconnect 0.11.0 "Facebook Connect"
cordova-plugin-crosswalk-webview 1.2.0 "Crosswalk WebView Engine"
cordova-plugin-google-analytics 0.7.2 "Google Universal Analytics Plugin"
cordova-plugin-network-information 1.0.2-dev "Network Information"
cordova-plugin-whitelist 1.0.0 "Whitelist"
de.appplant.cordova.plugin.local-notification 0.8.2dev "LocalNotification"
nl.x-services.plugins.launchmyapp 3.2.4 "Custom URL scheme"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.dialogs 0.3.0 "Notification"
org.apache.cordova.globalization 0.3.4 "Globalization"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"
org.apache.cordova.splashscreen 1.0.0 "Splashscreen"
org.apache.cordova.statusbar 0.1.10 "StatusBar"
org.pushandplay.cordova.apprate 1.1.7 "AppRate"
uerceg commented 9 years ago

Okay, since you're already using Google Play Services for Android, try with this:

https://github.com/adjust/cordova_sdk/#4-google-play-services

With special focus on this part:

If you don't want to use Google Play Services in your app, you can remove them by editing plugin.xml file of the adjust SDK plugin. Go to plugins/com.adjust.sdk folder and open plugin.xml file. As part of the <platform name="android">, you can find following line which adds Google Play Services dependency:

<framework src="com.google.android.gms:play-services-ads:+" />

If you want to remove Google Play Services, simply remove this line, save your changes and rebuild your app.

PS: You don't need to downgrade to v3.4.1, continue using v4.0.0 but with removing Google Play Services dependency from our plugin.

Let me know if it worked.

zwacky commented 9 years ago

hey @uerceg, that was exactly the issue. thanks for your fast response! big :+1: for adjust

zwacky commented 9 years ago

did all the right alterations and now i my startup event doesn't get tracked.

in the logcat i found the following:

E/AndroidRuntime( 7727): java.lang.RuntimeException: Unable to instantiate receiver com.adjust.sdk.AdjustReferrerReceiver: java.lang.ClassNotFoundException: Didn't find class "com.adjust.sdk.AdjustReferrerReceiver" on path: DexPathList[[zip file "/data/app/com.justwatch.justwatch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.justwatch.justwatch-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime( 7727): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.adjust.sdk.AdjustReferrerReceiver" on path: DexPathList[[zip file "/data/app/com.justwatch.justwatch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.justwatch.justwatch-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime( 7727):    Suppressed: java.lang.ClassNotFoundException: com.adjust.sdk.AdjustReferrerReceiver
E/AndroidRuntime( 8109): java.lang.RuntimeException: Unable to instantiate receiver com.adjust.sdk.AdjustReferrerReceiver: java.lang.ClassNotFoundException: Didn't find class "com.adjust.sdk.AdjustReferrerReceiver" on path: DexPathList[[zip file "/data/app/com.justwatch.justwatch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.justwatch.justwatch-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime( 8109): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.adjust.sdk.AdjustReferrerReceiver" on path: DexPathList[[zip file "/data/app/com.justwatch.justwatch-1/base.apk"],nativeLibraryDirectories=[/data/app/com.justwatch.justwatch-1/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime( 8109):    Suppressed: java.lang.ClassNotFoundException: com.adjust.sdk.AdjustReferrerReceiver
F/Adjust  (31309): PRODUCTION: Adjust is running in Production mode. Use this setting only for the build that you want to publish. Set the environment to `sandbox` if you want to test your app!
E/PluginManager(31309):     at com.adjust.sdk.AdjustCordova.jsonObjectToMapAdjustCordova.java:235)
E/PluginManager(31309):     at com.adjust.sdk.AdjustCordova.execute(AdjustCordova.java:123)

there is an adjust-android.jar and it also holds an AdjustReferrerReceiver.class inside. this build is without the <framework src="com.google.android.gms:play-services-ads:+" /> in the plugin.xml. any hints?

uerceg commented 9 years ago

@zwacky This looks strange. Can you show me your code where you are initialising our SDK and describe the flow of this scenario which leads to these problems?

If you like, feel free to write us an email to support@adjust.com and we can continue our conversation in there if you don't feel like sharing code snippets from your app in public.

zwacky commented 9 years ago

update: I created a blank new project with adjust sdk and I didn't get that message, that the AdjustReferrerReceiver.class couldn't be found. But instead I still got problems with the iOS build process - but I sent that over to support@adjust.com.