1

我已经查看了有关此错误的大多数其他线程,但没有找到答案。

几周前,我使用插件和带有插件的示例项目开始了一个新项目。添加了我自己的各种功能和设计,运行项目没有问题。

然后在 2 天前更新到 ADT 17,这对我来说严重搞砸了。开始出现类路径错误等等。然后我恢复到修复了错误的 adt 16,我的项目编译得很好,但是一旦我运行它,它就会在测试设备上崩溃。

我检查了我的合规级别是否正确,检查了库路径、api 版本、清单 xml,基本上所有内容。我不明白过去可以完美运行的东西现在如何无法正常工作。

我继续卸载所有东西,并在 sdk 的 ADT 和 java 上重新安装,但无济于事,即使只是尝试运行示例项目也会崩溃。

我还从设备上卸载了该应用程序并重新启动了设备并清除了缓存。我已经走到了尽头。就像我说的,我已经检查了库和所有内容,它只是这个运行时错误。

我还增加了连接超时,并在我的清单中添加了“android:installLocation="preferExternal",没有变化。

请帮忙,代码不会有问题,因为它运行良好。

请参阅启动活动的代码:

package com.yourcompany.junaioplugin.template;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;

import com.yourcompany.junaioplugin.template.R;

import com.metaio.junaio.plugin.JunaioPlugin;

public class SplashActivity extends Activity
{

static
{
    JunaioPlugin.loadNativeLibs();
}

/**
 * standard tag used for all the debug messages
 */
public static final String TAG = "junaioPluginTemplate";

/**
 * Display log messages with debug priority 
 * 
 * @param msg Message to display
 * @see Log#d(String, String)
 */
public static void log(String msg)
{
    if (msg != null)
        Log.d(TAG, msg);

}

/**
 * Progress dialog
 */
private ProgressDialog progressDialog;


 @Override
public void onCreate(Bundle savedInstanceState) 
{
     super.onCreate(savedInstanceState);

     setContentView( R.layout.main );

     JunaioStarterTask junaioStarter = new JunaioStarterTask();
     junaioStarter.execute(1);
}


private class JunaioStarterTask extends AsyncTask<Integer, Integer, Integer>
{

    @Override
    protected void onPreExecute()
    {
        progressDialog =  ProgressDialog.show(SplashActivity.this,            "junaio", "Starting up...");
    }

    @Override
    protected Integer doInBackground(Integer... params) 
    {

        // Set authentication if a private channel is used
//          JunaioPlugin.setAuthentication("username", "password");

        // Start junaio, this will initialize everything the plugin need
        int result = JunaioPlugin.startJunaio(this, getApplicationContext());

        return result;
    }

    @Override
    protected void onProgressUpdate(Integer... progress) 
    {

    }

    @Override
    protected void onPostExecute(Integer result) 
    {
        if (progressDialog != null)
        {
            progressDialog.cancel();
            progressDialog = null;
        }

        switch (result)
        {
        case JunaioPlugin.ERROR_EXSTORAGE:
            SplashActivity.log("External storage is not available, closing...");
            finish();
            break;
        case JunaioPlugin.ERROR_INSTORAGE:
            SplashActivity.log("Internal storage is not available, closing...");
            finish();
            break;
        case JunaioPlugin.CANCELLED:
            SplashActivity.log("Starting junaio cancelled");
            break;
        case JunaioPlugin.SUCCESS:
            JunaioPlugin.setAuthentication("junaioTester", "test123");
            launchLiveView();
            break;
        }
    }

}


/**
 * Launch junaio live view
 */
private void launchLiveView()
{

    startActivity(new Intent(this, JunaioARViewTestActivity.class));
    finish();
}

@Override
protected void onResume() 
{
    super.onResume();

}

@Override
protected void onPause()
{
    super.onPause();
}

@Override
protected void onStop()
{
    super.onStop();

    if (progressDialog != null)
    {
        progressDialog.cancel();
        progressDialog = null;
    }
}

}

这是日志猫:

    03-27 10:47:47.543: I/dalvikvm(10641): Could not find method                 com.metaio.junaio.plugin.JunaioPlugin.loadNativeLibs, referenced from method com.yourcompany.junaioplugin.template.SplashActivity.<clinit>

    03-27 10:47:47.543: W/dalvikvm(10641): VFY: unable to resolve static method 65: Lcom/metaio/junaio/plugin/JunaioPlugin;.loadNativeLibs ()V
    03-27 10:47:47.543: D/dalvikvm(10641): VFY: replacing opcode 0x71 at 0x0000
    03-27 10:47:47.543: D/dalvikvm(10641): VFY: dead code 0x0003-0003 in Lcom/yourcompany/junaioplugin/template/SplashActivity;.<clinit> ()V
    03-27 10:47:47.543: W/dalvikvm(10641): Unable to resolve superclass of Lcom/yourcompany/junaioplugin/template/JunaioARViewTestActivity; (48)
    03-27 10:47:47.543: W/dalvikvm(10641): Link of class 'Lcom/yourcompany/junaioplugin/template/JunaioARViewTestActivity;' failed
    03-27 10:47:47.547: E/dalvikvm(10641): Could not find class 'com.yourcompany.junaioplugin.template.JunaioARViewTestActivity', referenced from method com.yourcompany.junaioplugin.template.SplashActivity.launchLiveView
    03-27 10:47:47.547: W/dalvikvm(10641): VFY: unable to resolve const-class 78 (Lcom/yourcompany/junaioplugin/template/JunaioARViewTestActivity;) in Lcom/yourcompany/junaioplugin/template/SplashActivity;
    03-27 10:47:47.547: D/dalvikvm(10641): VFY: replacing opcode 0x1c at 0x0002
    03-27 10:47:47.547: D/dalvikvm(10641): VFY: dead code 0x0004-000d in Lcom/yourcompany/junaioplugin/template/SplashActivity;.launchLiveView ()V
    03-27 10:47:47.547: W/dalvikvm(10641): Exception Ljava/lang/NoClassDefFoundError; thrown during Lcom/yourcompany/junaioplugin/template/SplashActivity;.<clinit>
    03-27 10:47:47.547: W/dalvikvm(10641): Class init failed in newInstance call (Lcom/yourcompany/junaioplugin/template/SplashActivity;)
    03-27 10:47:47.547: D/AndroidRuntime(10641): Shutting down VM
    03-27 10:47:47.547: W/dalvikvm(10641): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
    03-27 10:47:47.555: E/AndroidRuntime(10641): FATAL EXCEPTION: main
    03-27 10:47:47.555: E/AndroidRuntime(10641): java.lang.ExceptionInInitializerError
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at java.lang.Class.newInstanceImpl(Native Method)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at java.lang.Class.newInstance(Class.java:1429)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.os.Handler.dispatchMessage(Handler.java:99)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.os.Looper.loop(Looper.java:123)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at android.app.ActivityThread.main(ActivityThread.java:4627)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at java.lang.reflect.Method.invokeNative(Native Method)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at java.lang.reflect.Method.invoke(Method.java:521)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at dalvik.system.NativeStart.main(Native Method)
    03-27 10:47:47.555: E/AndroidRuntime(10641): Caused by: java.lang.NoClassDefFoundError: com.metaio.junaio.plugin.JunaioPlugin
    03-27 10:47:47.555: E/AndroidRuntime(10641):    at com.yourcompany.junaioplugin.template.SplashActivity.<clinit>(SplashActivity.java:19)
    03-27 10:47:47.555: E/AndroidRuntime(10641):    ... 15 more

这是清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="3"
android:versionName="3.5.1" package="com.yourcompany.junaioplugin.template"
android:installLocation="preferExternal">

<!-- The application must be compiled using Google APIs (Android 3.0) -->
<!-- However, target and min SDK can be 8 (Android 2.2) -->
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus"   android:required="false"/>
<uses-feature android:name="android.hardware.location.gps"  android:required="false"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false"/>
<uses-feature android:name="android.hardware.sensor.compass" android:required="false"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />   

<application 
    android:label="@string/app_name" 
    android:icon="@drawable/icon" 
    android:debuggable="true">

    <uses-library android:name="com.google.android.maps" />

    <!-- Start screen -->
    <activity android:name=".SplashActivity"
              android:theme="@style/Theme.Fullscreen"
              android:screenOrientation="portrait"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <!-- junaio AR view activity -->
    <activity 
        android:name=".JunaioARViewTestActivity"
        android:theme="@style/Theme.Fullscreen"
        android:configChanges="orientation"
        android:screenOrientation="landscape">
    </activity>

    <activity 
        android:name="com.metaio.junaio.plugin.view.POIDetailDialog"
        android:theme="@style/Theme.POIDialog"
        android:screenOrientation="landscape">
    </activity>

    <activity 
        android:name="com.metaio.junaio.plugin.view.WebViewActivity"
        android:theme="@style/Theme.Fullscreen"
        android:configChanges="orientation">"
    </activity>

    <activity 
        android:name="com.metaio.junaio.plugin.view.ImageViewActivity"
        android:theme="@style/Theme.Fullscreen"
        android:configChanges="orientation">
    </activity>

</application>

</manifest>
4

1 回答 1

2

对我来说,当我安装 ADT 17 时,我在使用 3rd 方库时遇到了问题(它一直告诉我有重复)。事实证明,它们不再需要添加到构建路径中;只是保存在项目根目录中名为“libs”的文件夹中。这可能是同样的问题吗?

于 2012-03-27T10:11:59.117 回答