我为我的示例项目实现了 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?
有没有其他人有类似的情况?