我将我的应用程序与facebook sdk集成在一起。没有com.sromku,效果很好。
我尝试通过com.sromku依赖关系共享图像和文本(请参阅:Android: How to share image with text on facebook via intent?)。
我解决了与Facebook SDK冲突有关的问题。编译效果很好,但是在尝试运行应用程序时出现错误。 请帮助我解决错误。 错误如下:
vars <- colnames(mtcars)[-1]
# Prepare combinations of variables.
combos <- combn(vars, 2, simplify = FALSE)
combos <- sapply(combos, FUN = paste, collapse = "*")
# For each combination, create a formula object and use it in the regression.
# It would be prudent to include the data object into function argument.
results <- lapply(combos, FUN = function(x) {
frm <- as.formula(paste("mpg ~ ", x))
summary(lm(frm, data = mtcars))
})
# Rename results names for pretty purposes.
names(results) <- combos
> results[1]
$`cyl*disp`
Call:
lm(formula = frm, data = mtcars)
Residuals:
Min 1Q Median 3Q Max
-4.0809 -1.6054 -0.2948 1.0546 5.7981
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 49.037212 5.004636 9.798 1.51e-10 ***
cyl -3.405244 0.840189 -4.053 0.000365 ***
disp -0.145526 0.040002 -3.638 0.001099 **
cyl:disp 0.015854 0.004948 3.204 0.003369 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.66 on 28 degrees of freedom
Multiple R-squared: 0.8241, Adjusted R-squared: 0.8052
F-statistic: 43.72 on 3 and 28 DF, p-value: 1.078e-10
MainApp.java
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)
应用的build.gradle
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'
}
依赖关系树
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)'
}
非常感谢!