sbt run对于我编写的Spray示例应用程序,我收到一个奇怪的错误,它编译得很好,我只在我的个人计算机上得到错误,因为它在另一台计算机上工作正常.
这是我认为的相关来源,它是Spray示例代码的模板代码,但我不认为这是原因.
package spray.examples
import akka.actor.{ActorSystem, Props}
import akka.io.IO
import spray.can.Http
object Boot extends App {
implicit val system = ActorSystem()
// the handler actor replies to incoming HttpRequests
val handler = system.actorOf(Props[DemoServiceActor], name = "handler")
IO(Http) ! Http.Bind(handler, interface = "localhost", port = 8080)
}
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪
Uncaught error from thread [default-akka.actor.default-dispatcher-3] shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[default]
java.lang.VerifyError: (class: spray/can/server/HttpListener, method: <init> signature: (Lakka/actor/ActorRef;Lspray/can/Http$Bind;Lspray/can/HttpExt$Settings;)V) Incompatible argument to function
at spray.can.HttpManager$$anonfun$receive$1$$anonfun$applyOrElse$1.apply(HttpManager.scala:65)
at spray.can.HttpManager$$anonfun$receive$1$$anonfun$applyOrElse$1.apply(HttpManager.scala:65) …Run Code Online (Sandbox Code Playgroud) 我正在将一个应用程序从Eclipse移植到Android Studio,并且在尝试在API小于17的模拟器上运行应用程序时遇到验证错误.我很感激有关如何处理此问题的任何指导.这是在API 8仿真器上的logcat中显示的内容:
12-27 01:48:27.189 431-431/com.zigzagworld.icjl.tanachbible W/dalvikvm: VFY: register1 v10 type 12, wanted 10
12-27 01:48:27.189 431-431/com.zigzagworld.icjl.tanachbible W/dalvikvm: VFY: rejecting opcode 0x70 at 0x005e
12-27 01:48:27.189 431-431/com.zigzagworld.icjl.tanachbible W/dalvikvm: VFY: rejected Lcom/zigzagworld/fonts/GlyphMetrics;.<init> (SSS[S)V
12-27 01:48:27.189 431-431/com.zigzagworld.icjl.tanachbible W/dalvikvm: Verifier rejected class Lcom/zigzagworld/fonts/GlyphMetrics;
Run Code Online (Sandbox Code Playgroud)
紧接着就是应用程序崩溃后立即(毫不奇怪)java.lang.VerifyError.相同的.apk文件将在API级别17及更高级别上正常运行.API 17及更高版本有不同的代码路径,但GlyphMetrics无论API级别如何,都会在某些时候使用该类.(如果不同的代码路径可以对类在加载时是否生成验证错误产生影响,有人请告诉我!)
本GlyphMetrics类是关于我们在应用程序中使用一个自造的位图字体的一些规格信息,非常简单的容器:
package com.zigzagworld.fonts;
import static com.zigzagworld.fonts.Diacritics.LOWER_DIACRITIC;
import static com.zigzagworld.fonts.Diacritics.UPPER_DIACRITIC;
/**
* Represents the layout metrics for a glyph.
*
* @author Ted Hopp
*/
public final class GlyphMetrics {
public static final …Run Code Online (Sandbox Code Playgroud) 我无法在JBOSS EAP 7服务器上部署我的Spring BOOT REST应用程序。
但是,在Apache Tomcat 8服务器上部署后,它运行良好。
应用主类:
@SpringBootApplication(scanBasePackages= {"org.nic"})
@PropertySource(value="classpath:database.properties")
public class PopulationApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(PopulationApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(PopulationApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>org.nic.PopulationApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId> …Run Code Online (Sandbox Code Playgroud) 我最近向市场推出了我的应用程序,我一直在与一位用户联系,该用户报告说,当他启动我的应用程序时,它会显示强制关闭/报告对话框.我让用户报告错误,以便我可以看到正在发生的堆栈跟踪,并且我得到了java.lang.VerifyError.
根据我的阅读,这与外部库有关,或者在java.lang中的某些方法与目标Android SDK版本不兼容.
用户使用的是Android 2.2.1,但该应用程序目前可以在许多其他2.2设备上运行,所以我试图找出从哪里开始挖掘.
问题: 是否有人建议开始寻找问题的最佳方法是什么?如果需要,我可以提供代码或更多信息,所以请告诉我.
这是堆栈跟踪:
java.lang.VerifyError: com.app.myapp.MainActivity
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1429)
at android.app.Instrumentation.newActivity(Instrumentation.java:1034)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2749)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2866)
at android.app.ActivityThread.access$2300(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:5097)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
提前致谢!
编辑
根据康斯坦丁的要求添加
MainActivity.java
package com.app.myapp;
//Imports removed
public class MainActivity extends BaseActivity implements Runnable {
private LayoutInflater mInflater;
private SharedPreferences prefs;
private SharedPreferences.Editor prefsEditor;
....
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadActivity(savedInstanceState);
}
private …Run Code Online (Sandbox Code Playgroud) 我构建了一个Android应用程序.出于某种原因,我在某些设备(例如Samsung Galaxy)上获得VerifyError,而在其他设备上没有(例如在Nexus 5上).
抛出此行的异常:
AdManager.getInstance().preInit();
Run Code Online (Sandbox Code Playgroud)
exeption堆栈是:
java.lang.VerifyError: org/example/crossword/Ads/AdManager
at org.example.crossword.PuzzleActivity.onCreate(PuzzleActivity.java:55)
at android.app.Activity.performCreate(Activity.java:5255)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2213)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
at android.app.ActivityThread.access$700(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5306)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
在尝试找出导致问题的原因之后,我注意到我有这条线:
catch (ReflectiveOperationException e) { ...
Run Code Online (Sandbox Code Playgroud)
当我删除此行,并使用常规Exception时,不会发生VerifyError.
所以,我想知道为什么ReflectiveOperationException会在某些设备上导致此错误?
我没有使用 XML 文件来设置波纹可绘制的状态,而是使用 javanew RippleDrawable(color, backgroundDrawable, null) 构造函数,因为我在适配器中使用它,其中每个项目都有自己的颜色。该代码在棒棒糖后设备上按预期工作,但即使我添加了 SDK_INT 检查,它也会在棒棒糖前设备上崩溃并出现以下错误
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
holder.rootView.setBackground(getBackgroundDrawable(ColorConverter.lightenColor(Color.parseColor(item.getTextColor()), 0.6f), background));
}
Run Code Online (Sandbox Code Playgroud)
getBackgroundDrawable()
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static RippleDrawable getBackgroundDrawable(int pressedColor, Drawable backgroundDrawable) {
return new RippleDrawable(getPressedState(pressedColor), backgroundDrawable, null);
}
Run Code Online (Sandbox Code Playgroud)
getPressedState()
private static ColorStateList getPressedState(int pressedColor) {
return new ColorStateList(new int[][]{new int[]{}}, new int[]{pressedColor});
}
Run Code Online (Sandbox Code Playgroud)
错误堆栈跟踪
E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method com.test.app.adapter.util.DashboardButtonsAdapter.getBackgroundDrawable
12-11 18:40:07.745 14717-14717/com.test.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.app, PID: 14717
java.lang.VerifyError: com/test/app/adapter/util/DashboardButtonsAdapter
at com.test.app.fragment.dashboard.DashboardPageFragment.onCreateView(DashboardPageFragment.java:71) …Run Code Online (Sandbox Code Playgroud) 根据这个主题: 获取java.lang.VerifyError的原因
java.lang.VerifyError 获取执行jvm的版本是否比用于编译的jvm更新.
我们始终可以使用以下jvm选项解决此问题:-XX:-UseSplitVerifier.
根据这个:
使用此选项是"非常安全".
因此,我不明白为什么java.lang.VerifyError是阻止成功编译的问题.请澄清.也许对于检测字节码的库来说,它是不安全的?
我在调用Webservice communicator类中得到 java.lang.VerifyError.
此错误仅在Android 4.2 OS设备中出现.它在OS和Tabs的所有其他设备上运行良好.
以下是我的日志:
01-09 06:15:10.263: E/AndroidRuntime(785): FATAL EXCEPTION: Thread-78
01-09 06:15:10.263: E/AndroidRuntime(785): java.lang.VerifyError: org/ksoap2/SoapEnvelope
01-09 06:15:10.263: E/AndroidRuntime(785): at com.weg.ecatalogue.servercommunication.WebServiceCommunicator$2.run(WebServiceCommunicator.java:78)
01-09 06:15:10.263: E/AndroidRuntime(785): at java.lang.Thread.run(Thread.java:856)
Run Code Online (Sandbox Code Playgroud)
关于4.2 OS依赖问题,请建议我.
android ×5
java ×5
verifyerror ×5
akka ×1
bytecode ×1
eclipse ×1
gson ×1
jboss ×1
jboss-eap-7 ×1
jvm ×1
reflection ×1
sbt ×1
scala ×1
soap ×1
spray ×1
spring ×1
spring-boot ×1
web-services ×1