Api 10上的InflateException

时间:2014-09-28 10:22:14

标签: android version inflate-exception

我需要帮助! :)

我已经创建了一个差不多完成的应用程序,我已经在许多设备和许多Android版本上进行了测试。在Android L和KitKat上一切正常,但是当我尝试在Gingerbread上打开它时,它将无法启动。

这是我的主要活动:

public class MainActivity extends FragmentActivity {

private GoogleMap googleMap;
LocationManager locationManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE );

    if ( !manager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ) {
        showGPSDisabledAlertToUser();
    } else {

    setUpMapIfNeeded();

    }

    TextView txView = (TextView)findViewById(R.id.calculate);

... ECC

那是日志猫:

    09-28 09:53:01.320: E/AndroidRuntime(2766): FATAL EXCEPTION: main
09-28 09:53:01.320: E/AndroidRuntime(2766): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lifeapps.speedcalc/com.lifeapps.speedcalc.MainActivity}: android.view.InflateException: Binary XML file line #78: Error inflating class fragment
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.os.Looper.loop(Looper.java:130)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.ActivityThread.main(ActivityThread.java:3687)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at java.lang.reflect.Method.invokeNative(Native Method)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at java.lang.reflect.Method.invoke(Method.java:507)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at dalvik.system.NativeStart.main(Native Method)
09-28 09:53:01.320: E/AndroidRuntime(2766): Caused by: android.view.InflateException: Binary XML file line #78: Error inflating class fragment
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:626)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.Activity.setContentView(Activity.java:1657)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at com.lifeapps.speedcalc.MainActivity.onCreate(MainActivity.java:38)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
09-28 09:53:01.320: E/AndroidRuntime(2766):     ... 11 more
09-28 09:53:01.320: E/AndroidRuntime(2766): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.lifeapps.speedcalc-1.apk]
09-28 09:53:01.320: E/AndroidRuntime(2766):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.createView(LayoutInflater.java:471)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
09-28 09:53:01.320: E/AndroidRuntime(2766):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-28 09:53:01.320: E/AndroidRuntime(2766):     ... 21 more

问题在于:

setContentView(R.layout.activity_main);

但我不知道为什么。关于如何解决我的问题的任何想法?

P.S。 Android Manifest设置为minsdkversion:10。

1 个答案:

答案 0 :(得分:1)

Google地图片段仅从API级别12+开始提供。如果您需要旧版本,可以查看it