错误:发生了JNI错误.线程"main"中的异常java.lang.VerifyError.该位置的预期堆栈图框架 [英] Error: A JNI error has occurred. Exception in thread "main" java.lang.VerifyError. Expected stackmap frame at this location

查看:141
本文介绍了错误:发生了JNI错误.线程"main"中的异常java.lang.VerifyError.该位置的预期堆栈图框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试混淆使用appium jars的Java应用程序项目.

I am trying to obfuscate a java application project which uses appium jars.

当我使用gradle创建jar时,jar可以正常工作,但是当我混淆jar并尝试运行它时,出现以下错误.

When I create the jar using gradle build the jar works fine but when I obfuscate the jar and try to run it I get the following error.

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 77
Exception Details:
  Location:
    com/mobile/MobileTest/App.peformActions()V @0: new
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: bb00 1859 b700 254d 2c12 0c12 02b6 0026
    0x0000010: 2c12 0812 0db6 0026 2c12 0412 05b6 0026
    0x0000020: 2c12 0312 06b6 0026 bb00 1259 bb00 1559
    0x0000030: 120a b700 232c b700 204c 2b12 01b8 0024
    0x0000040: b600 1f4e 2db9 0027 0100 a700 084c 2bb6
    0x0000050: 0021 b1                                
  Exception Handler Table:
    bci [0, 74] => handler: 77

    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)

我也访问了许多类似的问题,但没有一个解决了我的问题

I have also visited many similar questions but none of them solved my issue

  • ProGuard JNI Error
  • Proguard - Error: A JNI error has occured

我尝试使用-dontpreverify对我不起作用

build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "net.sf.proguard:proguard-gradle:6.1.1"
    }
}
plugins {
    id 'java'
    id 'maven-publish'
}

repositories {
    maven {
        url = 'http://repo.maven.apache.org/maven2'
    }
}

dependencies {
    compile 'org.testng:testng:6.14.3'
    compile 'io.appium:java-client:7.0.0'
    compile 'org.apache.poi:poi:3.16'
    compile 'net.sourceforge.tess4j:tess4j:4.3.0'
    compile 'log4j:log4j:1.2.17'
    testCompile 'junit:junit:4.11'
}

group = 'com.mobile'
version = '0.1'
description = 'AppiumTest'
sourceCompatibility = '1.8'

publishing {
    publications {
        maven(MavenPublication) {
            from(components.java)
        }
    }
}

jar{
    duplicatesStrategy = 'exclude'
    from { configurations.compile.collect { zipTree(it) } }
    manifest {
        attributes 'Implementation-Title': 'Jar File with dependencies',  
            'Implementation-Version': version,
            'Main-Class': 'com.mobile.MobileTest.App'
    }
}

task proguardTask(type: proguard.gradle.ProGuardTask,dependsOn: jar) {
    configuration file('proguard.pro')
    injars 'build/libs/MobileTest-0.1.jar'
    outjars 'build/libs/MobileTest-0.1-obfus.jar'   
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

test {
    useTestNG()
}

proguard.config

-dontoptimize
-allowaccessmodification
-dontshrink
-dontwarn
-dontpreverify
-verbose
-keepattributes Signature
-keepattributes Exceptions
-adaptclassstrings
-keepdirectories
-keepclasseswithmembernames,includedescriptorclasses class * {
    native <methods>;}
-keep public class com.mobile.MobileTest.App {*;}
-keepclassmembernames public class com.mobile.MobileTest.App {*;}
-keep class module-info{*;}

-keep public class afu.**{*;}
-keep public interface afu.**{*;}
-keep public enum afu.**{*;}

-keep public class aj.org.objectweb.asm.**{*;}
-keep public interface aj.org.objectweb.asm.**{*;}
-keep public enum aj.org.objectweb.asm.**{*;}

-keep public class bsh.**{*;}
-keep public interface bsh.**{*;}
-keep public enum bsh.**{*;}

-keep public class ch.qos.logback.**{*;}
-keep public interface ch.qos.logback.**{*;}
-keep public enum ch.qos.logback.**{*;}

-keep public class com.beust.**{*;}
-keep public interface com.beust.**{*;}
-keep public enum com.beust.**{*;}

-keep public class com.github.jaiimageio.**{*;}
-keep public interface com.github.jaiimageio.**{*;}
-keep public enum com.github.jaiimageio.**{*;}

-keep public class com.google.**{*;}
-keep public interface com.google.**{*;}
-keep public enum com.google.**{*;}

-keep public class com.lowagie.**{*;}
-keep public interface com.lowagie.**{*;}
-keep public enum com.lowagie.**{*;}

-keep public class com.ochafik.lang.jnaerator.runtime.**{*;}
-keep public interface com.ochafik.lang.jnaerator.runtime.**{*;}
-keep public enum com.ochafik.lang.jnaerator.runtime.**{*;}

-keep public class com.recognition.software.jdeskew.**{*;}
-keep public interface com.recognition.software.jdeskew.**{*;}
-keep public enum com.recognition.software.jdeskew.**{*;}

-keep public class com.sun.jna.**{*;}
-keep public interface com.sun.jna.**{*;}
-keep public enum com.sun.jna.**{*;}

-keep public class gnu.cajo.**{*;}
-keep public interface gnu.cajo.**{*;}
-keep public enum gnu.cajo.**{*;}

-keep public class images.**{*;}
-keep public interface images.**{*;}
-keep public enum images.**{*;}

-keep public class io.appium.java_client.**{*;}
-keep public interface io.appium.java_client.**{*;}
-keep public enum io.appium.java_client.**{*;}

-keep public class javax.annotation.**{*;}
-keep public interface javax.annotation.**{*;}
-keep public enum javax.annotation.**{*;}

-keep public class kobaltBuild.classes.**{*;}
-keep public interface kobaltBuild.classes.**{*;}
-keep public enum kobaltBuild.classes.**{*;}

-keep public class mozilla.**{*;}
-keep public interface mozilla.**{*;}
-keep public enum mozilla.**{*;}

-keep public class net.**{*;}
-keep public interface net.**{*;}
-keep public enum net.**{*;}

-keep public class okhttp3.**{*;}
-keep public interface okhttp3.**{*;}
-keep public enum okhttp3.**{*;}

-keep public class okio.**{*;}
-keep public interface okio.**{*;}
-keep public enum okio.**{*;}

-keep public class org.**{*;}
-keep public interface org.**{*;}
-keep public enum org.**{*;}

任何帮助将不胜感激.

推荐答案

混淆在Java VM上运行的Java应用程序时,必须不要使用 -dontpreverify .它需要预验证信息,使用此选项可以禁用其生成.删除该选项,它应该可以工作.

You must not use -dontpreverify when obfuscating a java application that runs on a Java VM. It requires preverification information, with this option you disable the generation of it. Remove the option and it should work.

这篇关于错误:发生了JNI错误.线程"main"中的异常java.lang.VerifyError.该位置的预期堆栈图框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆