使用 sapjco 连接到 SAP 时出现问题。这是错误消息:
java.lang.ExceptionInInitializerError: JCo 初始化失败并出现 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/base.apk",压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_dependencies_apk.apk”,压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_resources_apk.apk”,压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_0_apk.apk”,压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_1_apk.apk”,压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_2_apk.apk”,压缩文件“/data/app/com.example.ecowb。ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_3_apk.apk”,压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_4_apk.apk”,压缩文件“/data/app/com.example.ecowb. ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_5_apk.apk”,压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_6_apk.apk”,压缩文件“/data/app/com.example.ecowb. ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_7_apk.apk”,压缩文件“/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_8_apk.apk”,压缩文件“/data/app/com.example.ecowb. ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/lib/arm64, /system/lib64,/system/vendor/lib64]]] 找不到“libsapjco3.so”
这是我的项目:
MainActivity.Java
package com.example.ecowb.ecowb;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.sap.conn.jco.AbapException;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;
import net.sf.json.JSON;
import net.sf.json.xml.XMLSerializer;
public class MainActivity extends AppCompatActivity {
static String ABAP_AS = "ABAP_AS_WITHOUT_POOL";
public static String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
static String ABAP_MS = "ABAP_MS_WITHOUT_POOL";
static boolean alreadyRegister;
private android.content.Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (this.alreadyRegister == true) {
return;
}
CustomDestinationDataProvider.MyDestinationDataProvider myProvider = new CustomDestinationDataProvider.MyDestinationDataProvider();
try {
com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(myProvider);
alreadyRegister = true;
} catch (IllegalStateException providerAlreadyRegisteredException) {
throw new Error(providerAlreadyRegisteredException);
}
// CustomDestinationDataProvider test = new
// CustomDestinationDataProvider();
myProvider.changeProperties(ABAP_AS_POOLED, CustomDestinationDataProvider.getDestinationPropertiesFromUI());
JCoDestination destination = null;
try {
destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
} catch (JCoException e) {
e.printStackTrace();
}
System.out.println("Attributes:");
try {
System.out.println(destination.getAttributes());
} catch (JCoException e) {
e.printStackTrace();
}
System.out.println();
}
这是我的 Gradle:
构建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.ecowb.ecowb"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "libsapjco3"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
splits {
abi {
enable true
reset()
include 'x86', 'armeabi'
universalApk true
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: 'native-libs.jar', dir: '$buildDir/native-libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
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.android.support:design:27.1.1'
implementation files('libs/json-lib-2.4-jdk15.jar')
implementation files('libs/sapjco3.09.jar')
}