简体   繁体   中英

Can't import library project into Android Studio project

I'm writing a library project to create a component that's going to be used in some, if not all, of our projects. I wanted to test how it's going so far, but I can't import the library project into my other project.

So, I created my library project called SplashScreen with Android Studio. Now I've created the project SplashScreenDemo with an Activity that should use the component I wrote in the library project. But the import wizard doesn't let me choose the project and all the info I find online is to import into Android Studio your old Eclipse library project, but in my problem Eclipse isn't involved at all.

So far I've tried:

  • Right click on project root > New > Module > Import Existing Project
  • File > Import Project
  • File > Import Module

This is the window (and that's the path to my library project):

向导窗口

I've tried several paths, none of them working:

  • /Users/dgc/AndroidStudioProjects/SplashScreen
  • /Users/dgc/AndroidStudioProjects/SplashScreen/SplashScreen.iml
  • /Users/dgc/AndroidStudioProjects/SplashScreen/build.gradle
  • /Users/dgc/AndroidStudioProjects/SplashScreen/app
  • /Users/dgc/AndroidStudioProjects/SplashScreen/app/app.iml
  • /Users/dgc/AndroidStudioProjects/SplashScreen/app/build.gradle

Any ideas? Am I missing something?

PS: Versions:

  • Android Studio 0.6.1
  • gradle 1.10
  • Android plugin 0.11.+

I think what's happening is that you're trying to import a module that has the same name as an existing module and it's not giving you any indication of what's wrong. Actually, if you enter just the path to the parent project so it will show you a list of modules you can import, and those modules can't be selected if you hover over one, it will show you the error message in a tooltip:

在此输入图像描述

Obviously that's not very helpful, and I've filed a bug asking for improvements:

https://code.google.com/p/android/issues/detail?id=71942

To work around it, you'll have to rename either the module you're trying to import or the module in your project. To do that you can right-click on it in project view, choose Refactor > Rename > Rename directory.

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