Я интегрирую свое приложение с Facebook SDK.Без ком.сромку, работает хорошо.
Я пытаюсь поделиться как изображением, так и текстом в зависимости от com.sromku (см .: Android: Как поделиться изображением с текстом на Facebook через намерение? ).
Я исправил проблему, связанную с конфликтом Facebook SDK.Компиляция работает хорошо, но я получаю ошибку, когда пытаюсь запустить свое приложение.Пожалуйста, помогите мне устранить ошибку.Ошибка, как показано ниже:
02/15 17:00:12: Launching app
$ adb install-multiple -r -t /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/resources/instant-run/debug/resources-debug.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/dep/dependencies.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_0.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_2.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_1.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_4.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_3.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_5.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_7.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_6.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_9.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/split-apk/debug/slices/slice_8.apk /home/haipv/02.workspace/personal/android/FBIntegration/app/build/intermediates/instant-run-apk/debug/app-debug.apk
Split APKs installed in 1 s 413 ms
$ adb shell am start -n "haipv.fbintegration/haipv.fbintegration.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: haipv.fbintegration.test | haipv.fbintegration
Waiting for application to come online: haipv.fbintegration.test | haipv.fbintegration
Waiting for application to come online: haipv.fbintegration.test | haipv.fbintegration
Waiting for application to come online: haipv.fbintegration.test | haipv.fbintegration
Waiting for application to come online: haipv.fbintegration.test | haipv.fbintegration
Connecting to haipv.fbintegration
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/zygote: Debugger is active
I/System.out: Debugger has connected
waiting for debugger to settle...
Connected to the target VM, address: 'localhost:8602', transport: 'socket'
I/chatty: uid=10083(haipv.fbintegration) identical 5 lines
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1368)
I/InstantRun: starting instant run server: is main process
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: haipv.fbintegration, PID: 18103
java.lang.NoSuchMethodError: No static method getAPIVersion()Ljava/lang/String; in class Lcom/facebook/internal/ServerProtocol; or its super classes (declaration of 'com.facebook.internal.ServerProtocol' appears in /data/app/haipv.fbintegration-Lh6BEOxTLqD3iSGVIs4jig==/split_lib_dependencies_apk.apk)
at com.sromku.simple.fb.SimpleFacebookConfiguration$Builder.<init>(SimpleFacebookConfiguration.java:166)
at haipv.fbintegration.MainApp.onCreate(MainApp.java:19)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
MainApp.java
package haipv.fbintegration;
import android.app.Application;
import com.sromku.simple.fb.Permission;
import com.sromku.simple.fb.SimpleFacebook;
import com.sromku.simple.fb.SimpleFacebookConfiguration;
public class MainApp extends Application {
@Override
public void onCreate() {
Permission[] permissions = new Permission[] {
Permission.USER_PHOTOS,
Permission.EMAIL
};
super.onCreate();
SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
.setAppId(getString(R.string.facebook_app_id))
.setPermissions(permissions)
.build();
SimpleFacebook.setConfiguration(configuration);
}
}
build.gradle приложения
....
configurations.all {
resolutionStrategy.eachDependency {
DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "26.+"
}
}
}
}
configurations {
compile.exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.ext.supportLibraryVersion"
implementation "com.github.bumptech.glide:glide:$rootProject.ext.glideVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "com.jakewharton:butterknife:$rootProject.ext.butterknifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.ext.butterknifeVersion"
implementation "com.facebook.android:facebook-android-sdk:$rootProject.ext.facebookVersion"
implementation "com.facebook.android:facebook-share:$rootProject.ext.facebookVersion"
implementation "com.facebook.android:facebook-login:$rootProject.ext.facebookVersion"
implementation 'com.sromku:simple-fb:4.1.1'
}
build.gradle проекта
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
minSdkVersion = 16
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '27.0.2'
supportLibraryVersion = '27.1.1'
retrofitVersion = '2.0.0-beta4'
dbflowVersion = '3.0.0-beta3'
butterknifeVersion = '8.8.1'
facebookVersion = '[4,5)'
eventbusVersion = '3.0.0'
daggerVersion = '2.0.1'
glideVersion = '3.6.1'
jsr250Version = '1.0'
glideVersion = '4.8.0'
facebookVersion = '[4,5)'
}
дерево зависимостей
+--- com.android.support:recyclerview-v7:27.1.1 -> 26.1.0
| +--- com.android.support:support-annotations:26.1.0
| +--- com.android.support:support-compat:26.1.0
| | +--- com.android.support:support-annotations:26.1.0
| | \--- android.arch.lifecycle:runtime:1.0.0
| | +--- android.arch.lifecycle:common:1.0.0
| | \--- android.arch.core:common:1.0.0
| \--- com.android.support:support-core-ui:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| \--- com.android.support:support-compat:26.1.0 (*)
+--- com.android.support:appcompat-v7:27.1.1 -> 26.1.0
| +--- com.android.support:support-annotations:26.1.0
| +--- com.android.support:support-v4:26.1.0
| | +--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-media-compat:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-utils:26.1.0
| | | +--- com.android.support:support-annotations:26.1.0
| | | \--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0 (*)
| | \--- com.android.support:support-fragment:26.1.0
| | +--- com.android.support:support-compat:26.1.0 (*)
| | +--- com.android.support:support-core-ui:26.1.0 (*)
| | \--- com.android.support:support-core-utils:26.1.0 (*)
| +--- com.android.support:support-vector-drawable:26.1.0
| | +--- com.android.support:support-annotations:26.1.0
| | \--- com.android.support:support-compat:26.1.0 (*)
| \--- com.android.support:animated-vector-drawable:26.1.0
| +--- com.android.support:support-vector-drawable:26.1.0 (*)
| \--- com.android.support:support-core-ui:26.1.0 (*)
+--- com.android.support:cardview-v7:27.1.1 -> 26.1.0
| \--- com.android.support:support-annotations:26.1.0
+--- com.android.support:support-v4:27.1.1 -> 26.1.0 (*)
+--- com.android.support:design:27.1.1 -> 26.1.0
| +--- com.android.support:support-v4:26.1.0 (*)
| +--- com.android.support:appcompat-v7:26.1.0 (*)
| +--- com.android.support:recyclerview-v7:26.1.0 (*)
| \--- com.android.support:transition:26.1.0
| +--- com.android.support:support-annotations:26.1.0
| \--- com.android.support:support-v4:26.1.0 (*)
+--- com.github.bumptech.glide:glide:4.8.0
| +--- com.github.bumptech.glide:gifdecoder:4.8.0
| | \--- com.android.support:support-annotations:27.1.1 -> 26.1.0
| +--- com.github.bumptech.glide:disklrucache:4.8.0
| +--- com.github.bumptech.glide:annotations:4.8.0
| \--- com.android.support:support-fragment:27.1.1 -> 26.1.0 (*)
+--- com.android.support.constraint:constraint-layout:1.1.3
| \--- com.android.support.constraint:constraint-layout-solver:1.1.3
+--- com.jakewharton:butterknife:8.8.1
| +--- com.jakewharton:butterknife-annotations:8.8.1
| | \--- com.android.support:support-annotations:25.3.0 -> 26.1.0
| +--- com.android.support:support-annotations:25.3.0 -> 26.1.0
| \--- com.android.support:support-compat:25.3.0 -> 26.1.0 (*)
+--- com.facebook.android:facebook-share:[4,5) -> 4.40.0
| +--- com.facebook.android:facebook-core:4.40.0
| | +--- com.parse.bolts:bolts-android:1.4.0
| | | +--- com.parse.bolts:bolts-tasks:1.4.0
| | | \--- com.parse.bolts:bolts-applinks:1.4.0
| | | \--- com.parse.bolts:bolts-tasks:1.4.0
| | +--- com.android.support:support-annotations:27.0.2 -> 26.1.0
| | \--- com.android.support:support-core-utils:27.0.2 -> 26.1.0 (*)
| \--- com.facebook.android:facebook-common:4.40.0
| +--- com.facebook.android:facebook-core:4.40.0 (*)
| +--- com.android.support:support-v4:27.0.2 -> 26.1.0 (*)
| +--- com.android.support:appcompat-v7:27.0.2 -> 26.1.0 (*)
| +--- com.android.support:cardview-v7:27.0.2 -> 26.1.0 (*)
| +--- com.android.support:customtabs:27.0.2 -> 26.1.0
| | +--- com.android.support:support-compat:26.1.0 (*)
| | \--- com.android.support:support-annotations:26.1.0
| \--- com.google.zxing:core:3.3.0
+--- com.facebook.android:facebook-login:[4,5) -> 4.40.0
| +--- com.facebook.android:facebook-core:4.40.0 (*)
| +--- com.facebook.android:facebook-common:4.40.0 (*)
| \--- com.android.support:appcompat-v7:27.0.2 -> 26.1.0 (*)
+--- com.sromku:simple-fb:4.1.1
| \--- com.google.code.gson:gson:1.7.2
\--- junit:junit:4.12
\--- org.hamcrest:hamcrest-core:1.3
Большое спасибо !!!