Geofences(Android示例应用程序)java.lang.ClassNotFoundException MainActivity

Geofences(Android示例应用程序)java.lang.ClassNotFoundException MainActivity,android,geolocation,classnotfoundexception,geofencing,android-geofence,Android,Geolocation,Classnotfoundexception,Geofencing,Android Geofence,我有一个ASUS Eee选项卡(Transformer Prime TF201 Android v4.1.1)。我正在阅读地理围栏上的API,并将下面的示例应用下载到我的设备=> . 但当我打开它时,它就终止了 我已经在AndroidManifest.xml文件中设置了目标sdk=16 LogCat 06-04 19:39:34.176: E/AndroidRuntime(2596): FATAL EXCEPTION: main 06-04 19:39:34.176: E/AndroidRunt

我有一个ASUS Eee选项卡(Transformer Prime TF201 Android v4.1.1)。我正在阅读地理围栏上的API,并将下面的示例应用下载到我的设备=> . 但当我打开它时,它就终止了

我已经在AndroidManifest.xml文件中设置了目标sdk=16

LogCat

06-04 19:39:34.176: E/AndroidRuntime(2596): FATAL EXCEPTION: main
06-04 19:39:34.176: E/AndroidRuntime(2596): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.geofence/com.example.android.geofence.MainActivity}: java.lang.ClassNotFoundException: com.example.android.geofence.MainActivity
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.os.Looper.loop(Looper.java:137)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.app.ActivityThread.main(ActivityThread.java:4745)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at java.lang.reflect.Method.invokeNative(Native Method)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at java.lang.reflect.Method.invoke(Method.java:511)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at dalvik.system.NativeStart.main(Native Method)
06-04 19:39:34.176: E/AndroidRuntime(2596): Caused by: java.lang.ClassNotFoundException: com.example.android.geofence.MainActivity
06-04 19:39:34.176: E/AndroidRuntime(2596):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
06-04 19:39:34.176: E/AndroidRuntime(2596):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
06-04 19:39:34.176: E/AndroidRuntime(2596):     ... 11 more

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2013 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.geofence"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />

    <!--
        Requests address-level location access, which is usually
        necessary for geofencing
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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

        <!-- The app's entry point -->
        <activity
            android:name="com.example.android.geofence.MainActivity"
            android:label="@string/title_activity_geofence" >
            <intent-filter>
                <!--
                    This activity is triggered when the system
                    tries to start the app's main activity
                -->
                <action android:name="android.intent.action.MAIN" />

                <!--
                    This activity should be linked to the app's Launcher icon
                 -->
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name="com.example.android.geofence.ReceiveTransitionsIntentService" android:exported="false"></service>
    </application>

</manifest>

@stud91我已经从上面的Url下载了示例项目,并且我已经更改了一些基本内容

  • 创建“libs”文件夹
  • 放入android-support-v4.jar和google-play-services.jar文件
  • 并运行示例项目,它就像一个魅力。 您可以从“adt-bundle-windows-x86\sdk\extras\google\google\u play\u services\libproject\google-play-services\u lib\libs中找到google-play-services\u lib” 我想你已经用Goolge软件包删除了这个软件包。删除为此项目创建的所有引用。清理您的示例项目并享受。 和

    根据Android官方团队的说法,u应该在Android模拟器上运行AVD,AVD运行基于Android 4.2.2或更高版本的Google API平台

    在geofences trianing link中说:

    Note: To make your app compatible with platform version 1.6 and later, the activity that displays the DialogFragment must subclass FragmentActivity instead of Activity. Using FragmentActivity also allows you to call getSupportFragmentManager() to display the DialogFragment. 
    

    我在启动扩展
    MapActivity
    活动时遇到了同样的问题。要找到答案需要一些时间和研究。在manifest.xml的
    application
    标签下添加
    uses library
    ,为我解决了这个问题:

    <uses-library android:name="com.google.android.maps" />
    
    
    
    发布您的日志,或者请提供更多信息。
    ClassNotFoundException:com.example.android.geopfence.MainActivity
    查看您的包和类中是否有正确的名称。也在清单中。您的项目配置文件是什么?可能是您没有为APK导出设置正确的类。我怀疑问题与此类似: