在Android Studio

时间:2016-08-22 08:44:12

标签: java android android-studio exception intellij-idea

在Android Studio中,我的布局文件的设计窗口存在渲染问题。即使在模拟器中,应用程序也能正常工作。这就是它所说的那样,因为我选择了设计窗口:

  

java.lang.NoClassDefFoundError:无法初始化类   org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants     在   org.osmdroid.tileprovider.MapTileProviderArray.getMapTile(MapTileProviderArray.java:93)     在   org.osmdroid.views.overlay.TilesOverlay $ 1.handleTile(TilesOverlay.java:182)     在org.osmdroid.util.TileLooper.loop(TileLooper.java:34)at   org.osmdroid.views.overlay.TilesOverlay.drawTiles(TilesOverlay.java:161)     在   org.osmdroid.views.overlay.TilesOverlay.draw(TilesOverlay.java:148)     在   org.osmdroid.views.overlay.DefaultOverlayManager.onDraw(DefaultOverlayManager.java:107)     在org.osmdroid.views.MapView.dispatchDraw(MapView.java:996)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:17070)at   com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:387)     在   com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:498)     在com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:434)     在   com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)     在   com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:520)     在   com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:508)     在   com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)     在   com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)     在   com.android.tools.idea.rendering.RenderTask.access $ 600(RenderTask.java:75)     在   com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:620)     在   com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:617)     在   com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)     在   com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)     在   com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)     在   com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel $ 7.run(AndroidDesignerEditorPanel.java:519)     在   com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)     在   com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)     在   com.intellij.util.ui.update.MergingUpdateQueue $ 3.run(MergingUpdateQueue.java:271)     在   com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)     在   com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)     在   com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)     在   com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)     在com.intellij.util.Alarm $ Request $ 1.run(Alarm.java:352)at   java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)     在java.util.concurrent.FutureTask.run(FutureTask.java:266)at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617)     在java.lang.Thread.run(Thread.java:745)

只要按下刷新按钮,错误消息就会变为:

  

java.lang.NullPointerException at   android.os.storage.StorageManager.getVolumeList(StorageManager.java:922)     在   android.os.Environment $ UserEnvironment.getExternalDirs(Environment.java:87)     在   android.os.Environment.getExternalStorageDirectory(Environment.java:404)     在   org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants。(OpenStreetMapTileProviderConstants.java:24)     在   org.osmdroid.tileprovider.MapTileProviderArray.getMapTile(MapTileProviderArray.java:93)     在   org.osmdroid.views.overlay.TilesOverlay $ 1.handleTile(TilesOverlay.java:182)     在org.osmdroid.util.TileLooper.loop(TileLooper.java:34)at   org.osmdroid.views.overlay.TilesOverlay.drawTiles(TilesOverlay.java:161)     在   org.osmdroid.views.overlay.TilesOverlay.draw(TilesOverlay.java:148)     在   org.osmdroid.views.overlay.DefaultOverlayManager.onDraw(DefaultOverlayManager.java:107)     在org.osmdroid.views.MapView.dispatchDraw(MapView.java:996)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:16973)at   android.view.ViewGroup.drawChild_Original(ViewGroup.java:3764)at   android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61)     在android.view.ViewGroup.drawChild(ViewGroup.java:3764)at   android.view.ViewGroup.dispatchDraw(ViewGroup.java:3550)at   android.view.View.draw(View.java:17070)at   com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:387)     在   com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:498)     在com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:434)     在   com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)     在   com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:520)     在   com.android.tools.idea.rendering.RenderTask $ 2.compute(RenderTask.java:508)     在   com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)     在   com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)     在   com.android.tools.idea.rendering.RenderTask.access $ 600(RenderTask.java:75)     在   com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:620)     在   com.android.tools.idea.rendering.RenderTask $ 3.call(RenderTask.java:617)     在   com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)     在   com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)     在   com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)     在   com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel $ 7.run(AndroidDesignerEditorPanel.java:519)     在   com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)     在   com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)     在   com.intellij.util.ui.update.MergingUpdateQueue $ 3.run(MergingUpdateQueue.java:271)     在   com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)     在   com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)     在   com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)     在   com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)     在com.intellij.util.Alarm $ Request $ 1.run(Alarm.java:352)at   java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)     在java.util.concurrent.FutureTask.run(FutureTask.java:266)at   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     在   java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617)     在java.lang.Thread.run(Thread.java:745)

这是我的主要活动:

        import android.app.Activity;
        import android.os.Bundle;
        import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
        import org.osmdroid.views.MapView;

public class MainActivity extends Activity {
    @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //important! set your user agent to prevent getting banned from the osm servers
        org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);

        MapView map = (MapView) findViewById(R.id.map);
        map.setTileSource(TileSourceFactory.MAPNIK);
    }
}

这是清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.x.x_x">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name="com.example.x.x_x.MainActivity" >
        </activity>
    </application>

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

</manifest>

有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

OSMDroid没有为AndroidStudio / IntelliJ提供能够显示视图的信息。这个特殊错误说的是AndroidStudio正在尝试使用给定的&#34; tile&#34;进行预览。来自OSRDroid并且还没有提供磁贴(因为它是以编程方式而不是通过XML完成的)。

如果您想查看结果,则必须运行该应用程序。