Some small changes in Android studio 3.0

preface

Early in the morning, in the crowded subway in Beijing, my CTO, brother Yan, sent me a message on wechat: Android studio 3.0 was released.

Why pay so much attention to the release of Android studio 3.0? This is mainly because the new app to be developed by the company is ready to use the kotlin language, and Android studio 3.0 has built in the kotlin language support, which saves a lot of trouble. If you haven't contacted the kotlin language, you can go to Baidu's official website. If you use the Java language now, you're really lucky, because kotlin is for you, It will be very simple. For example, someone like me can cope with most of the development in two or three days.

I won't describe the kotlin language too much here. Today's focus is the story after I upgraded to Android studio 3.0.

text

Come to the company, open the computer, upgrade Android studio to version 3.0, and compile the current project. Oh, why did I make so many mistakes? Don't worry, let's solve these problems slowly.

Android studio comes with gradle version 4.1 and plug-in version 3.0.0, so if you use the old version, there will be some small compatibility problems. Let's see what errors are reported:

Question 1

Error:(72,0) Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_ Decorated{apkData=Main{type=MAIN,fullName=appDebug,filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.

OutputFile is a read-only property and cannot be modified

Take a look at the code in my gradle:

The function of this code is to modify the name of the APK generated by the build command. Because the outputFile becomes a read-only attribute, an error is reported.

After modification:

Change each to all, and then modify the name of the generated APK through outputfilename.

If you are prompted that the all method is not found or the outputfilename is not found, you can comment out this function first, and then open it after other problems are solved.

Question 2

Error:All flavors must Now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

All flavor attributes should belong to the same namespace

The problem seems a little esoteric. In fact, we need to set up a version for flavors and use the same version of flavors uniformly.

Question 3

Some libraries can't be referenced normally, such as the multidex I use. In the screenshot above, we have been prompted how to solve this problem

Question 4

Error:(2638) error: style attribute '@android:attr/windowEnterAnimation' not found.

Tips: we can't find @ Android: attr / windowenteranimation because it doesn't support the use of Android's own attributes at the beginning of @ any more. We just need to delete the @ symbol.

Before modification:

After modification:

Question 5

Error:Execution Failed for task ':app:javaPreCompileAppDebug'. Annotation processors must be explicitly declared Now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - butterknife-6.1.0.jar (com.jakewharton:butterknife:6.1.0) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with prevIoUs behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

There are a lot of error logs. In fact, the first two lines are the most critical:

When using the annotation compilation library, you need to display the declaration, and the butterknife I am using contains the annotation compilation function, but it does not have a declaration.

terms of settlement:

Other changes

Through the modification just now, my project has run, but I found several small changes in Android studio 3.0.

Change 1

Warning:One of the plugins you are using supports Java 8 language features. To try the support built into the Android plugin,remove the following from your build.gradle: apply plugin: 'me.tatarka.retrolambda'

Judging from the warning, I hope I can remove this plug-in, so I checked the information on the official website:

If Android Studio detects that your project is using Jack,Retrolambda,or dexguard,the IDE uses Java 8 support provided by those tools instead.

If Android studio finds that Jack, retroambda or dexguard is used in your project, the editor will use Java 8 support to replace this tool. Because I use the third-party framework me.tatarka.retroambda, this occurs. We just need to delete the relevant configuration.

Change 2

Prompt for a later version of your third-party framework:

The screenshot above shows that gson has a higher version 2.8.3, prompting me to upgrade gson. This saves us the time to check whether the version is updated on GitHub, which is very convenient.

summary

This is the problem and solution I encountered today. If there are more problems before, please add them.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>