Okay, so I can't develop nothing as my Android Studio decided to. My all project is full of errors, unknown errors caused by Android Studio.
note: my files are correct, it is an other problem because even if I will import something from google codes it will have errors.
When I import a project everything's fine, but then after indexing and such things, all sudden everything is red and shouldn't be.
My errors for example are :
button1.setOnLongClickListener(new View.OnLongClickListener()
{
....
....
}
Well shouldn't be error but : cannot resolve symbol setOnLongClickListener
Another example:
button1=(Button) findViewById(R.id.button1);
I used this exact code for other button, seems right, I always using this line, it was fine until my Android Studio decided to give me some hard time, this line is full by errors and they are:
Unknown class: 'button1' , invalid method declaration; return type required, missing method body, or declare abstract
and there are like 20 errors that shouldn't be, things I tried:
My Module: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'
}
Also I noticed now, my Manifest file as an error in android:name=".MainActivity"
says it has no default structure. something like this. here is the full normal code:
<?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>
Please, if someone knows what is the problem or what can I else do, just say, and I am sorry about my English, thank you all.
What I've seen is my code is full of errors, but it still builds fine and deploys fine to the device.
To fix it:
For me I upgraded my Kotlin Version from 1.4 to 1.5.0 and it is now working.
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Afterwards I did a clean and a Rebuild and everything worked fine thereafter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With