0

我需要将 AppsFlyer SDK 集成到简单的 WebView 应用程序中并收到此错误:

当我使用

`com.appsflyer: af-android-sdk: 5.4.3`

它给出了这样的日志(我通过appsflyer对logcat进行了排序):


2020-08-03 02:29:49.680 4226-4226/com.example.fp D/AppsFlyer_5.4.3: Initializing AppsFlyer SDK: (v5.4.3.50)
2020-08-03 02:29:49.753 4366-4387/? D/LR-AppUsageStatsFactory: loadTodayTotalTimeForPackage()......pkgName=com.appsflyer.android.deviceid
2020-08-03 02:29:52.133 4226-4523/com.example.fp I/AppsFlyerOaid5.4.2: Failed resolution of: Lcom/bun/miitmdid/core/JLibrary;
2020-08-03 02:29:52.133 4226-4523/com.example.fp I/AppsFlyerOaid5.4.2: Fetch 2 ms
2020-08-03 02:30:02.320 4638-4647/? W/dex2oat: Compilation of java.util.Map com.appsflyer.AppsFlyerLibCore.ɩ(com.appsflyer.AFEvent) took 112.286ms

然后我想可能是包的版本,想改成稍微年轻一点的

`com.appsflyer: af-android-sdk: 5.4.0`

但这并没有修复错误,而只是添加了变量:


2020-08-03 02:10:46.983 30989-30989/com.example.fp D/AppsFlyer_5.4.0: Initializing AppsFlyer SDK: (v5.4.0.38)
        2020-08-03 02:10:47.309 31109-31130/? D/LR-AppUsageStatsFactory: loadTodayTotalTimeForPackage()......pkgName=com.appsflyer.android.deviceid
        2020-08-03 02:10:48.475 30989-31242/com.example.fp I/AppsFlyerOaid5.4.0: Fetch
            java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bun/miitmdid/core/JLibrary;
                at com.appsflyer.oaid.OaidClient.fetchMsa(OaidClient.java:76)
                at com.appsflyer.oaid.OaidClient.fetch(OaidClient.java:64)
                at com.appsflyer.AppsFlyerLibCore.ɩ(:50602)
                at com.appsflyer.AppsFlyerLibCore.ı(:1583)
                at com.appsflyer.AppsFlyerLibCore.ι(:98)
                at com.appsflyer.AppsFlyerLibCore$e.run(:3282)
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
                at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
                at com.appsflyer.AFExecutor$1$1.run(:31)
                at java.lang.Thread.run(Thread.java:764)
             Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bun.miitmdid.core.JLibrary" on path: DexPathList[[zip file "/data/app/com.example.fp-OGvp3y28P_JulNIhy4hUSg==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.fp-OGvp3y28P_JulNIhy4hUSg==/lib/arm64, /system/lib64]]
                at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                at com.appsflyer.oaid.OaidClient.fetchMsa(OaidClient.java:76) 
                at com.appsflyer.oaid.OaidClient.fetch(OaidClient.java:64) 
                at com.appsflyer.AppsFlyerLibCore.ɩ(:50602) 
                at com.appsflyer.AppsFlyerLibCore.ı(:1583) 
                at com.appsflyer.AppsFlyerLibCore.ι(:98) 
                at com.appsflyer.AppsFlyerLibCore$e.run(:3282) 
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) 
                at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) 
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
                at com.appsflyer.AFExecutor$1$1.run(:31) 
                at java.lang.Thread.run(Thread.java:764) 
        2020-08-03 02:21:06.729 2309-2372/? D/LR-AppUsageStatsFactory: loadTodayTotalTimeForPackage()......pkgName=com.appsflyer.android.deviceid

我在互联网上没有找到解决我的问题的方法。因此,我将非常感谢任何帮助。

我所有的代码都在下面。

构建.gradle(应用程序)

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.8'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.1"

    defaultConfig {
        manifestPlaceholders = [
                onesignal_app_id: 'ece0edc7-1ea8-4e98-9fc6-5c81e00a5b69',
                onesignal_google_project_number: 'REMOTE'
        ]
        applicationId "com.example.fp"
        minSdkVersion 18
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
//integration Appsflyer
repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.appsflyer:af-android-sdk:5.4.3'
    implementation 'com.android.installreferrer:installreferrer:2.1'
    implementation 'com.onesignal:OneSignal:3.15.2'
    implementation 'com.facebook.android:facebook-android-sdk:7.0.0'
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.fp">

    <uses-permission android:name="android.permission.INTERNET" />
    <!-- Intagration appsflyer -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!-- Optional : -->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:name=".AFApplication"
        android:allowBackup="true"
        android:fullBackupContent="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="Instantiatable"
        tools:replace="android:fullBackupContent">
        <receiver android:name="com.appsflyer.SingleInstallBroadcastReceiver" android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MainActivity.java

public class MainActivity extends Activity {


    WebView webView;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        // OneSignal Initialization
        OneSignal.startInit(this)
                .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
                .unsubscribeWhenNotificationsAreDisabled(true)
                .init();
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        webView = (WebView) findViewById(R.id.webView);
        webView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return super.shouldOverrideUrlLoading(view, url);
            }
        });

        webView.setWebChromeClient(new WebChromeClient() {
            public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
                return super.onJsAlert(view, url, message, result);
            }
        });
        webView.loadUrl("https://1wbmn.xyz/casino/");
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
            webView.goBack();
            return true;
        } else {
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }
    class AFApplication extends Application {
        private static final String AF_DEV_KEY = "qrdZGj123456789";

        @Override
        public void onCreate() {
            super.onCreate();
            AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() {


                @Override
                public void onConversionDataSuccess(Map<String, Object> conversionData) {

                    for (String attrName : conversionData.keySet()) {
                        Log.d("LOG_TAG", "attribute: " + attrName + " = " + conversionData.get(attrName));
                    }
                }

                @Override
                public void onConversionDataFail(String errorMessage) {
                    Log.d("LOG_TAG", "error getting conversion data: " + errorMessage);
                }

                @Override
                public void onAppOpenAttribution(Map<String, String> attributionData) {

                    for (String attrName : attributionData.keySet()) {
                        Log.d("LOG_TAG", "attribute: " + attrName + " = " + attributionData.get(attrName));
                    }

                }

                @Override
                public void onAttributionFailure(String errorMessage) {
                    Log.d("LOG_TAG", "error onAttributionFailure : " + errorMessage);
                }
            };

            AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionListener, this);
            AppsFlyerLib.getInstance().startTracking(this);

        }
    }
}
4

1 回答 1

0

看起来它可能根本不是问题:https ://github.com/AppsFlyerSDK/appsflyer-unity-plugin/issues/30

于 2020-08-07T18:42:40.187 回答