我遇到的问题是我有一个依赖 Parse 的现有项目。我的问题是如何集成 Adobe CreativeSDKImage,因为它扩展了 MultiDexApplication,而 Parse Application (Class) 扩展了 Application。
现有项目,例如(MyApp 扩展应用程序)导入 android.app.Application;
CreativeSDK 基于ADOBE CREATIVE SDK IMAGE GUIDE eg (CreativeSDKImageSampleApp extends) import android.support.multidex.MultiDexApplication;
经过数小时试图弄清楚为什么我的应用程序现在每次启动时都会崩溃之后,我注意到 Parse.initilize 是问题所在,或者如果我错了可能会纠正我,因为我也怀疑扩展 MultiDexApplication 可能是原因。我在这里阅读了使用 MultiDexApplication 的限制供您参考;建立多元
所以请看下面的代码,以帮助我将 Parse 与 CreativeSDKImage 应用程序集成。
package com.aviary.android.sample;
import android.support.multidex.MultiDexApplication;
import com.aviary.android.feather.sdk.IAviaryClientCredentials;
import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseUser;
public class MyApplication extends MultiDexApplication implements IAviaryClientCredentials {
@Override
public void onCreate() {
super.onCreate();
init();
}
private void init() {
// Enable Local Datastore.
Parse.enableLocalDatastore(getApplicationContext());
// Add your initialization code here
Parse.initialize(this);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// Optionally enable public read access.
// defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
}
@Override
public String getBillingKey() {
return "";
}
@Override
public String getClientID() {
return "YOUR CLIENT ID";
}
@Override
public String getClientSecret() {
return "YOUR CLIENT SECRET";
}
}
运行代码时出现此错误;
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: FATAL EXCEPTION: main
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: Process: com.aviary.android.sample, PID: 3700
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: java.lang.NoSuchMethodError: No virtual method setFollowRedirects(Z)V in class Lcom/squareup/okhttp/OkHttpClient; or its super classes (declaration of 'com.squareup.okhttp.OkHttpClient' appears in /data/app/com.aviary.android.sample-1/base.apk)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.parse.ParseOkHttpClient.<init>(ParseOkHttpClient.java:58)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.parse.ParseHttpClient.createClient(ParseHttpClient.java:45)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.parse.ParsePlugins$Android.newHttpClient(ParsePlugins.java:175)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.parse.ParsePlugins.restClient(ParsePlugins.java:91)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.parse.Parse.initialize(Parse.java:196)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.parse.Parse.initialize(Parse.java:161)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.aviary.android.sample.MyApplication.init(MyApplication.java:22)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.aviary.android.sample.MyApplication.onCreate(MyApplication.java:14)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at android.app.ActivityThread.-wrap1(ActivityThread.java)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
10-29 16:09:56.741 3700-3700/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-29 16:0
构建 Gradle 如下
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
project(':external:calendar') {
apply plugin: 'android-library'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
}
project(':external:colorpicker') {
apply plugin: 'android-library'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
}
project(':external:datetimepicker') {
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:22.2.1'
}
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
}
project(':external:timezonepicker') {
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:22.2.1'
}
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
}
project(':external:ex:chips') {
apply plugin: 'android-library'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
lintOptions {
abortOnError false
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
compile project(':external:calendar')
compile project(':external:colorpicker')
compile project(':external:datetimepicker')
compile project(':external:timezonepicker')
compile project(':external:ex:chips')
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile project(':ParseUI-Login')
}
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src', 'external/ex/common/java']
// NOTE: this includes external/ex/common/java!
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
/*
* To sign release build, create file gradle.properties in ~/.gradle/ with this content:
*
* signingStoreLocation=/home/key.store
* signingStorePassword=xxx
* signingKeyAlias=alias
* signingKeyPassword=xxx
*/
if (project.hasProperty('signingStoreLocation') &&
project.hasProperty('signingStorePassword') &&
project.hasProperty('signingKeyAlias') &&
project.hasProperty('signingKeyPassword')) {
println "Found sign properties in gradle.properties! Signing build…"
signingConfigs {
release {
storeFile file(signingStoreLocation)
storePassword signingStorePassword
keyAlias signingKeyAlias
keyPassword signingKeyPassword
}
}
buildTypes.release.signingConfig = signingConfigs.release
} else {
buildTypes.release.signingConfig = null
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}