SoFunction
Updated on 2025-03-01

Android Studio upgrade to 3.0 solution

Solution

First, write down the method, the cause, process and principle at the end, and look at the solution directly in a hurry.

Generally, this error is caused by using provided

For example, my old configuration is as follows:

Project file:

buildscript {
 dependencies {
  classpath ':gradle:3.0.1'
  // need delete in  version
  classpath ':android-apt:1.8'
 }
}
Module document:
apply plugin: ''
apply plugin: 'android-apt'
android {
 // ...
}
configurations {
 provided
}
dependencies {
 // ...
 // Fyber Annotations
 provided ':fyber-annotations:1.3.0'
 apt ':fyber-annotations-compiler:1.4.0'
 // ...
}

Change to the latest build. configuration:

Project file:

buildscript {
 dependencies {
  classpath ':gradle:3.0.1'
 }
}
Module document:
apply plugin: ''
android {
 // ...
 // add this code to enable annotationProcessor
  javaCompileOptions {
   annotationProcessorOptions {
    includeCompileClasspath = true
   }
  }
}
dependencies {
 // ...
 // Fyber Annotations
 compileOnly ':fyber-annotations:1.3.0'
 annotationProcessor ':fyber-annotations-compiler:1.4.0'
 // ...
}

After changing the above configuration, it will run successfully in the build Project. If not, please read:

Notes:

The configuration of the above Module must be written in the Module where the use annotation is located!

For example, I use @FyberSDK annotation in MainActivity in Module A, so I write the above configuration in Module A's file.

@FyberSDK
public class MainActivity extends BaseActivity<MainPresenter, MainModel> implements
  IBannerDelegate, IMainView,
   {
  //....
  }

Supplement related knowledge

Introduction to apt

1. What is APT?

APT (Annotation Processing Tool) is a tool for processing annotations. It detects source code files and finds out the Annotation in it, and automatically generates code based on the annotations. When Annotation comes out, the Annotation processor can generate additional source files and other files based on the Annotation in the source file (the specific content of the file is determined by the writer of the Annotation processor). APT will also compile the generated source files and the original source files and generate the class files together.

2、annotationProcessor

annotationProcessor is a type of APT tool. It is a built-in framework developed by Google. It does not need to be introduced and can be used directly in files.

3、android-apt

android-apt is an apt framework developed by a developer himself. The source code is hosted here. With the release of Android Gradle plug-in version 2.2, the Android Gradle plug-in provides a function called annotationProcessor to completely replace android-apt. Since then, the author of android-apt has issued a statement on the official website. The latest Android Gradle plug-in now supports annotationProcessor, warning and or blocking android-apt, and recommends everyone to use the official Android plug-in annotationProcessor.

other

New configuration Corresponding outdated configuration describe
implementation compile module compile time is available, module consumer runtime is available, for projects that use library, it can significantly increase the compilation time because it can reduce the build system to recompile some modules. Most apps/tests are used because of this configuration.
api compile The module is available when compiling, and the module's consumer compilation and runtime are available, which is the same as the outdated compile. Generally, the library module will use it. If the app module must use it, it must be used when it wants to expose the API to the test module.
compileOnly provided module is available when compiling, but the module consumer is not available when compiling and running. Same as outdated provided.
runtimeOnly apk module and its users are available at runtime. It is the same as outdated apk.

Summarize

The above is the prompt for upgrading Android Studio to 3.0 that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!