我遇到的问题是我有一个依赖于Parse的现有项目。我的问题是如何集成Adobe CreativeSDKImage,因为它 扩展MultiDexApplication,而Parse Application(Class)扩展Application。
现有项目 例如(MyApp extends Application)导入android.app.Application;
基于ADOBE CREATIVE SDK IMAGE GUIDE的CreativeSDK 例如(CreativeSDKImageSampleApp extends)import android.support.multidex.MultiDexApplication;
经过几个小时试图找出我的应用程序现在每次启动时崩溃的原因,我注意到Parse.initilize是问题,或者如果我错了可能会纠正我,因为我也怀疑扩展MultiDexApplication可能是原因。我在这里阅读了使用MultiDexApplication的限制作为参考; BUILDING MULTIDEX
因此,请查看下面的代码,以帮助我将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
Build 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
}
}
答案 0 :(得分:2)
这可能是因为鸟舍图像组件使用okhttp 1.6.0而parse使用同一个库的2.4.0版本。
如果您在项目上运行gradle :dependencies
,您会注意到只有okhttp:1.6.0被链接。
如果你更新了你的gradle依赖项,添加okhttp 2. *,它应该可以工作(虽然只是快速测试):
compile 'com.adobe.creativesdk:image:4.0.0'
compile 'com.parse.bolts:bolts-android:1.2.1'
compile 'com.parse:parse-android:1.10.3'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'