【发布时间】:2017-04-08 14:28:11
【问题描述】:
我正在编写一个需要提取 7z 档案的 Android 应用程序。时间紧迫,我正在搜索可以在我的项目中使用的第三方库或源代码。
我将 .so 文件复制到 /libs 文件夹中
app\src\main\jniLibs\armeabi\libun7z.so
我无法在 android 中提取 7z 文件
AndUn7z.extract7z(My7z, My7zPath);
运行此行后出现此错误:
java.lang.UnsatisfiedLinkError: No implementation found for int com.darkgamers.pepsiman.browser.mainmenu.AndUn7z.un7zip(java.lang.String, java.lang.String) (试过 Java_com_darkgamers_pepsiman_browser_mainmenu_AndUn7z_un7zip 和 Java_com_darkgamers_pepsiman_browser_mainmenu_AndUn7z_un7zip__Ljava_lang 在 com.darkgamers.pepsiman.browser.mainmenu.AndUn7z.un7zip(Native Method)
这是我的代码:
public class AndUn7z {
public static boolean extract7z(String filePath, String outPath)
{
File outDir = new File(outPath);
if(!outDir.exists() || !outDir.isDirectory())
{
outDir.mkdirs();
}
return (AndUn7z.un7zip(filePath, outPath) == 1);
}
/**
* Extract from assets
* @param context
* @param assetPath
* @param outPath
* @return
* @throws Exception
*/
public static boolean extractAssets(Context context, String assetPath, String outPath)
{
File outDir = new File(outPath);
if(!outDir.exists() || !outDir.isDirectory())
{
outDir.mkdirs();
}
String tempPath = outPath + File.separator + ".temp";
try {
copyFromAssets(context, assetPath, tempPath);
} catch (Exception e) {
e.printStackTrace();
return false;
}
boolean ret = (AndUn7z.un7zip(tempPath, outPath) == 1);
new File(tempPath).delete();
return ret;
}
/**
* Copy asset to temp
* @param context
* @param assetPath
* @param tempPath
* @throws Exception
*/
private static void copyFromAssets(Context context, String assetPath, String tempPath)
throws Exception
{
InputStream inputStream = context.getAssets().open(assetPath);
FileOutputStream fileOutputStream = new FileOutputStream(tempPath);
int length = -1;
byte[] buffer = new byte[0x400000];
while ((length = inputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, length);
}
fileOutputStream.flush();
fileOutputStream.close();
inputStream.close();
}
//JNI interface
private static native int un7zip(String filePath, String outPath);
static {
System.loadLibrary("un7z");
}
}
【问题讨论】:
-
任何错误输出?
-
问题已更新。
-
请任何人帮助我 - 我无法处理这个