AppsFlyer返回状态代码400

时间:2015-10-29 11:26:54

标签: android appsflyer appsflyer-android-sdk

我为我的示例项目实现了Appsflyer,但是当我运行它时,服务器返回错误代码400.

I/AppsFlyer_1.18-117182240: response code: 400

有我的MainActivty.java

public class MainActivity extends AppCompatActivity {

public static final String LOG_TAG = "AppsFlyerSampleApp";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
    // Set the Currency
    AppsFlyerLib.setCurrencyCode("USD");

    // The Dev key cab be set here or in the manifest.xml
    AppsFlyerLib.setAppsFlyerKey("aaaa");
    AppsFlyerLib.sendTracking(this);

    AppsFlyerLib.registerConversionListener(this, new AppsFlyerConversionListener() {
        public void onInstallConversionDataLoaded(Map<String, String> conversionData) {
            DebugLogQueue.getInstance().push("\nGot conversion data from server");
            for (String attrName : conversionData.keySet()) {
                Log.d(LOG_TAG, "attribute: " + attrName + " = " + conversionData.get(attrName));
            }
        }

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

        public void onAppOpenAttribution(Map<String, String> attributionData) {
            printMap(attributionData);
        }

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

        }

        private void printMap(Map<String, String> map) {
            for (String key : map.keySet()) {
                Log.d(LOG_TAG, key + "=" + map.get(key));
            }

        }
    });
}

我的清单文件。

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

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

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="appsflyer" />
            <!--<data android:scheme="http"-->
            <!--android:host="sometest.com"  />-->
        </intent-filter>
    </activity>

    <receiver
        android:name="com.appsflyer.MultipleInstallBroadcastReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.appsflyer.AppsFlyerLib">
        <intent-filter>
            <action android:name="android.intent.action.PACKAGE_REMOVED" />
            <data android:scheme="package" />
        </intent-filter>
    </receiver>
</application>

我不知道为什么服务器会输出错误代码400? 还有其他人得到类似案件吗?

3 个答案:

答案 0 :(得分:0)

我认为您应该检查您的applicationId,并确保您已在Appsflyer仪表板中使用相同的applicationId创建了您的应用。

我有相同的错误代码,直到我在applicationId中发现拼写错误我在Appsflyer上创建我的测试应用程序...

希望它会有所帮助

答案 1 :(得分:0)

经过数小时的搜索,我找到了解决方案。

我没有使用正确的Appsflyer密钥。有两个键

  1. API密钥:集成-> API访问->您的API密钥
  2. 开发密钥:配置->应用设置-> SDK安装

使用dev键签出安装。

希望这会有所帮助。

答案 2 :(得分:0)

尝试在 Release 变体中构建和运行。还要设置 debuggable true 以确保 AppsFlyer 正常工作,并且您可以在 Logcat 中查看安装日志

相关问题