好的,所以我不能像我的 Android Studio 决定的那样开发任何东西。 我的所有项目都充满了错误,Android Studio 导致的未知错误。
注意:我的文件是正确的,这是另一个问题,因为即使我从谷歌代码中导入一些东西,它也会有错误。
当我导入一个项目时一切正常,但是在索引和类似的事情之后,突然一切都是红色的,不应该是。
例如我的错误是:
button1.setOnLongClickListener(new View.OnLongClickListener()
{
....
....
}
应该不是错误但是:cannot resolve symbol setOnLongClickListener
另一个例子:
button1=(Button) findViewById(R.id.button1);
我为其他按钮使用了这个确切的代码,似乎是正确的,我一直使用这一行,它很好,直到我的 Android Studio 决定给我一些困难,这一行充满了错误,它们是:
Unknown class: 'button1' , invalid method declaration; return type required, missing method body, or declare abstract
并且有大约 20 个不应该出现的错误,我尝试过的事情:
- 删除 iml 文件、.idea 文件夹 - 工作了一段时间,但现在又发生了,但无法修复。
- 重新安装 android studio,然后导入项目。
- 正在将 android studio 版本升级到 1.3
- 重新启动我的电脑。
- 将项目导入另一台电脑,发生在一段时间后。
- 使缓存无效/重新启动。
- 更改项目结构中的模块 - 我将其改回原来的样子(没有帮助),我认为它导致了 list 错误......
我的模块:app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "firstappdevelopments.david.reactiontime"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
我现在还注意到,我的 Manifest 文件在 android:name=".MainActivity"
中作为错误表示它没有默认结构。像这样的东西。这是完整的正常代码:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
</manifest>
请,如果有人知道问题是什么或我还能做什么,请说,我对我的英语感到抱歉,谢谢大家。
最佳答案
关于Android Studio 充满了错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31792393/