简体   繁体   中英

How to automatically add 'implementation' line to new project

I'm currently taking an Android application development course, and I have a question regarding whenever I set up a new project. Since I'm early on in the learning process, I'm creating quite a few projects just to get the swing of things and make a habit of the entire process. One of the things I've come across is I whenever I create a new project, I get this error:

> Conflict with dependency 'com.android.support:support-annotations' in
project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1)
differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html
for details.

I've resolved this error whenever I create a project, thanks to this helpful post .

All I have to do is add a single line of code to my build.gradle (module app) file under dependencies, and all is well:

implementation 'com.android.support:support-annotations:28.0.0'

Is there some way to do this automatically? I know I'm not running the latest version of Android SDK (I'm on 3.0, building Ice Cream Sandwich), and it might get fixed if I update, but I'd prefer for now to stay in the version I'm on since it's what is specified in the course I'm taking. It really doesn't take that much time to do, but it would be handy to not have to add this line manually every time I make a new project. I have searched Google, and haven't found any relevant StackExchange posts, and none of the Android Developers pages I saw seemed to have anything helpful.

TL;DR: My code doesn't work unless I add a dependency line to my gradle file. How can I set this to happen automatically for each project I create, instead of inserting it manually each time?

I'm not entirely sure how to answer this directly, but my question did become resolved when I finally updated Android Studio SDK to the latest version. Default projects now work find without having to add an extra 'implementation' line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM