Copyright notice: This article is an original article of the blogger, shall not be reproduced without the permission of the blogger, wechat public account “Drunk Weng Cat” special author

Pay attention to me, every day there are high-quality technical articles push, work, study tired when relax yourself.

Welcome to follow my wechat official account: “Drunken Cat”

R files are missing in Android Studio, so how do you solve this problem? Re-examine the XML file in the resource file

If the r.java file was not generated during the last build, the references to the resources in the project will all fail. Usually, this is a code error in an XML layout file, and you need to check for it here, save the errors you find, and the R.Java file won’t go viral.

Clean up the project

Select the Build — Clean Project menu item and Android Studio will recompile the entire Project to eliminate errors. This is recommended often.

Gradle synchronizes projects

“Sync File with Gradle Files”. This button is used to resynchronize the dependencies of your project with gradle files. If you modify the build.gradle configuration file, you will need to update the compilation Settings of your Project simultaneously. Choose Tools – >Android – >Sync Project with Gradle Files menu item. Android Studio recompiles the project with the correct project Settings. This is to solve problems caused by Gradle configuration changes.

Declare the activity in the Android manifest configuration file

The manifest configuration file is an XML file containing metadata, and all activities for each application must be declared in the Mainfest configuration file so that the operating system can use them.

Oh, oh.. Creating a new Activity

At least three files are involved: Java classes, XML cloth, and the mainfest file for the application.

The object of the Intent

Intent objects are a medium that Component uses to communicate with the operating system. The only component we’ve seen so far is an activity. In fact there are: service, broadcast, receiver,… In fact, I have not contacted these, do not understand, when the understanding, I will write an article out.

Intents are multipurpose communication tools anyway. The Intent class provides multiple constructors.

In the AndroidManifest. In the XML

<activity android:name=".QuizActivity">
 <intent-filter>
  <action android:name="android.intent.action.MAIN"/>
  <category android:name="android.intent.category.LAUNCHER"/>
 </intent-filter>
</activity>
Copy the code

SDK concept In Android Studio, the lowest version setting is the standard SDK, and the operating system will refuse to install applications on Settings that are lower than the standard system version.

SDK target version: Indicates at application design time which API level is used to run.

SDK builds: In Android Studio, the lowest and target builds are notified to the operating system, and SDK builds are a little secret between us and the compiler. (Little secrets not to tell)

Android features are represented by classes and methods in the SDK. When compiling code, the SDK build version or build target specifies that the system version is to be used. You can modify the SDK version in the file.

Gradle is the lowest SDK version, target version, and build version in the build.gradle file.

    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "cn.edu.gdmec.android.geoquiz"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner       
        "android.support.test.runner.AndroidJUnitRunner"
    }
Copy the code

After making the changes, click on the Tools – >Android – >Sync Project with Gradle Files menu item and the Project will be recompiled and ready to go.

There’s another Android Lint thing, which is… Note that the Code you wrote above crashes when running on devices in earlier versions. Click Analyze — > Inspect Code… The menu item manually triggers Lint.

The reason for the crash is that the SDK builds to API level, there is no problem with the compiler itself compiling the code, but Android Lint knows the lowest version of the project SDK, so there is a problem.

Learning android developers in the document, it is recommended that: document home page is: http://developer.android.com/

Note taking from entry to familiarity!

Never give up!

If you like this article, please click the image below to follow the subscription account Drunken Weng Cat and watch more exciting content