amplitude / unity-plugin

Official Amplitude Unity Plugin
https://developers.amplitude.com/docs/unity
MIT License
44 stars 34 forks source link

[build error] #42

Closed phamhuong8794 closed 4 years ago

phamhuong8794 commented 4 years ago

I am trying build a new project with amplitude same tutorial. but app is crash immediately when i open app. this is error: Capture Capture2 Capture3

haoliu-amp commented 4 years ago

Hello, it's not a bug. Please make sure you follow the step 2 from our doc. https://developers.amplitude.com/docs/unity

phamhuong8794 commented 4 years ago

thanks for answer. i'd build success but have a error when i'm trying log an event. this is error in picture Capture

phamhuong8794 commented 4 years ago

if you have video setup, please send me

phamhuong8794 commented 4 years ago

image image image image image

haoliu-amp commented 4 years ago

@phamhuong8794 Can you try add

-keep class com.amplitude.unity.plugins.AmplitudePlugin { *; }

to your Proguard exceptions file?

phamhuong8794 commented 4 years ago

An error if i change this proguard: -keep class com.amplitude.unity.plugins.AmplitudePlugin { *; }

2020-06-25 09:41:37.651 27740-27740/? E/Zygote: isWhitelistProcess - Process is Whitelisted 2020-06-25 09:41:37.652 27740-27740/? E/libpersona: scanKnoxPersonas 2020-06-25 09:41:37.652 27740-27740/? E/libpersona: Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory 2020-06-25 09:41:38.246 27740-27740/com.android.application E/AndroidRuntime: FATAL EXCEPTION: main Process: com.android.application, PID: 27740 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/unity3d/player/UnityPlayer; at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:7) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.unity3d.player.UnityPlayer" on path: DexPathList[[zip file "/data/app/com.android.application-QqsCvCzcpl4HUeWyktLyiw==/base.apk"],nativeLibraryDirectories=[/data/app/com.android.application-QqsCvCzcpl4HUeWyktLyiw==/lib/arm, /data/app/com.android.application-QqsCvCzcpl4HUeWyktLyiw==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.unity3d.player.UnityPlayerActivity.onCreate(Unknown Source:7)  at android.app.Activity.performCreate(Activity.java:7183)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)  at android.app.ActivityThread.-wrap11(Unknown Source:0)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)  at android.os.Handler.dispatchMessage(Handler.java:105)  at android.os.Looper.loop(Looper.java:164)  at android.app.ActivityThread.main(ActivityThread.java:6944)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

haoliu-amp commented 4 years ago

This error seems strange. I'm not sure why your proguard is behaving this way.

The idea is not to obfuscate com.amplitude.unity.plugins.AmplitudePlugin class and its methods.

Which is this -

-keep class com.amplitude.unity.plugins.AmplitudePlugin

I don't think that's the issue in our tutorial. Maybe you can create a clean project to test it out.

phamhuong8794 commented 4 years ago

i'm create 4 times new project, and result is same. have issue of unity version??? i'm working in unity 2017.4.31f1. I'm don't find every package name is com.amplitude.unity.plugins.AmplitudePlugin in package

haoliu-amp commented 4 years ago

2017? That's too old. We're on 2019.3.11f.

Also that class is inside our android sdk.

phamhuong8794 commented 4 years ago

Do I need to import that sdk into the project?

phamhuong8794 commented 4 years ago

i trying up to unity 2018.4.23f1, it same (@@)

phamhuong8794 commented 4 years ago

If possible, please give me a video of how to add the library

phamhuong8794 commented 4 years ago

Thanks haoliu, I have finished adding amplitude to my project. There are some issues that hopefully help someone in need:

  1. i'm update version unity to 2018
  2. user lastest resolve jar
  3. replace -keep class com.amplitude.unity.plugins.AmplitudePlugin { *; } instead -keep class com.amplitude.unity.plugins.AmplitudePlugin
  4. This is how to add proguard file into unity: https://stackoverflow.com/questions/43774062/crashlytics-unity-plugin-export-to-android-studio/46840109#46840109 Goodluck!!
haoliu-amp commented 4 years ago

@phamhuong8794 Glad you figured it out! Thanks for sharing the steps too!