Android最新的开发环境运行原来环境开发的程序报java.lang.ClassNotFoundException错误解决

在更新到最新Android开发环境后,运行原有程序出现java.lang.ClassNotFoundException异常。问题根源可能是.classPath文件变动。解决方法涉及检查并调整.classPath文件中的android:maxSdkVersion设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天下载了一个最新的android开发环境,进行使用,但是在使用过程中遇到了一个问题,很纠结,下面就这个问题给大家分享,

以前原来的程序包含viewpager时,在运行时会报出java.lang.ClassNotFoundException异常,纠结了很久才解决。


最后总结分析,总结了这样的错误,应该是.classPath文件发生了变化。


之前的.classpath文件是:

<?xml version="1.0" encoding="UTF-8"?>  
<classpath>  
    <classpathentry kind="src" path="src"/>  
    <classpathentry kind="src" path="gen"/>  
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>  
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>  
    <classpathentry kind="output" path="bin/classes"/>  
</classpath> 

现在使用最新版本编译过的是.classpath文件是:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
	<classpathentry kind="output" path="bin/classes"/>
</classpath>



后来我又新建了一个工程,发现.classPath文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
	<classpathentry kind="output" path="bin/classes"/>
</classpath>

此时却别就出来了:

即将这个

<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>  
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>  

改成这个就可以了

<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>  
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>  

然后再次运行就可以了



android:minSdkVersion — 指明该应用程序可以运行的API最低版本。默认是“1”。
android:targetSdkVersion — 指明该应用程序设计时期望运行的目标API版本。在某些情况下,这允许应用程序使用目标API级别下定义的清单元素或行为,而不是只限于使用最低API级别定义的内容。

android:maxSdkVersion — 指明该应用程序可以运行的最高API级别。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值