我尝试添加到我的应用Google Tag Manger引荐跟踪器。我使用此文档:https://developers.google.com/tag-manager/android/v4/ua
在代码下面添加我的Maniferst:
<service android:name="com.google.tagmanager.InstallReferrerService" />
<receiver android:name="com.google.tagmanager.InstallReferrerReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
现在使用文档进行测试和验证:https://developers.google.com/analytics/solutions/testing-play-campaigns
我是通过adb发送的
echo 'am broadcast \
-a com.android.vending.INSTALL_REFERRER \
-n "pl.my.app/com.google.tagmanager.InstallReferrerReceiver" \
--es "referrer" \
"utm_source=test_source&utm_medium=test_medium&utm_term=test_term&utm_content=test_content&utm_campaign=test_name"; \
exit' | ./adb shell
我的应用程序崩溃了:
java.lang.RuntimeException: Unable to instantiate receiver com.google.tagmanager.InstallReferrerReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.tagmanager.InstallReferrerReceiver" on path: DexPathList[[zip file "/data/app/pl.my.app-2/base.apk"],nativeLibraryDirectories=[/data/app/pl.my.app-2/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1431)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.tagmanager.InstallReferrerReceiver" on path: DexPathList[[zip file "/data/app/pl.my.app-2/base.apk"],nativeLibraryDirectories=[/data/app/pl.my.app-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2719)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1431)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Suppressed: java.lang.ClassNotFoundException: com.google.tagmanager.InstallReferrerReceiver
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
知道发生了什么事吗?
我想我应该在gladle中添加一些东西。我想那个
compile 'com.google.android.gms:play-services-tagmanager:9.4.0'
还不够。
答案 0 :(得分:2)
TagManager的内容为play-services-analytics
在build.gradle
compile 'com.google.android.gms:play-services-analytics:9.4.0'
如谷歌文档中所述,您的清单应该满足于此:
<!-- Used for install referrer tracking-->
<service android:name="com.google.android.gms.tagmanager.InstallReferrerService" />
<receiver
android:name="com.google.android.gms.tagmanager.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
您的包名称似乎错误:com.google.tagmanager.InstallReferrerService
答案 1 :(得分:0)
我的react-native
应用中出现了这样的错误。
更改android\app\build.gradle
文件的这一部分:
像这样更新以前的:react-native-google-analytics-bridge
代码:
implementation(project(":react-native-google-analytics-bridge"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
然后像这样更改您的firebase
代码:
...
//implementation 'com.google.firebase:firebase-core'
//implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
...
然后在文件底部的android\gradle.properties
中添加
firebaseCoreVersion=16.0.8
firebaseMessagingVersion=17.6.0