将github项目作为库导入android studio中的现有项目的问题?

时间:2023-01-27 10:30:09

I know similar questions have been asked many times in the past, I'm working to try import a Github project to be a library Github Project for my existing project. I've reference to related * solutions discussed here for the steps (visually or setting.gradle/build.gradle code solution) to import it but without any success in it.

我知道过去曾多次询问过类似的问题,我正在尝试将Github项目导入我现有项目的库Github项目。我已经参考了这里讨论的相关*解决方案的步骤(visual或者.gradle / build.gradle代码解决方案)来导入它但没有任何成功。

Tried including include ':library:CanvasView' into setting.gradle and compile project(':library:CanvasView')into build.gradle

尝试包括':library:CanvasView'到setup.gradle和编译项目(':library:CanvasView')到build.gradle

Had error statement Error:Configuration with name 'default' not found. Tried solutions here to solve it without any success.

有错误声明错误:找不到名称为'default'的配置。在这里尝试解决方案,但没有任何成功。

But for once, I've managed to gradle compile it with this statement, compile it fileTree(dir: 'library', include: ['CanvasView']) in build.gradle

但是有一次,我已经设法用这个语句来编译它,在build.gradle中编译它的fileTree(dir:'library',include:['CanvasView'])

To my dismay, I realize that I was not able to call the API of the library in my main project, because the java file of the imported library was marked with an red icon. Tried solutions here but isn't helping to call the API. Thanks for any help rendered!

令我沮丧的是,我意识到我无法在我的主项目中调用库的API,因为导入库的java文件标有红色图标。这里尝试了解决方案,但没有帮助调用API。感谢您提供的任何帮助!

1 个解决方案

#1


0  

Make sure you have the right names. Note this is assuming you have already checkout your project from github. I usually put the projects under the same workspace directory. Like such:

确保你有正确的名字。请注意,假设您已经从github签出了您的项目。我通常将项目放在同一个工作区目录下。像这样:

-Workspace
          --MyApp
          --SomeLib

1.In your settings.gradle make sure you are pointing to the right place. My example:

1.在你的settings.gradle中确保你指向正确的位置。我的例子:

include ':SomeLib'
project (':SomeLib').projectDir = new File('../SomeLib/SomeLib')

2.In your build gradle make sure you are compiling the right Module name

2.在构建gradle中,确保编译正确的模块名称

compile project(':SomeLib')

A good check to see if you are doing things correctly at step 1. Before you go to step 2 make sure the library comes to the Project View. If it comes make sure your actual source code is there. Java classes etc. If you see that stuff then go to step 2. From step 2 you should be good. Let me know how it goes.

在第1步中检查您是否正确执行操作。在转到步骤2之前,请确保库已进入项目视图。如果它来了,请确保您的实际源代码存在。 Java类等。如果你看到那些东西,那么转到第2步。从第2步你应该是好的。让我知道事情的后续。

To be exact this is your example: settings.gradle

确切地说,这是你的例子:settings.gradle

include ':CanvasView'
project (':CanvasView').projectDir = new File('../CanvasView/CanvasView')

build.gradle

compile project(':CanvasView')

#1


0  

Make sure you have the right names. Note this is assuming you have already checkout your project from github. I usually put the projects under the same workspace directory. Like such:

确保你有正确的名字。请注意,假设您已经从github签出了您的项目。我通常将项目放在同一个工作区目录下。像这样:

-Workspace
          --MyApp
          --SomeLib

1.In your settings.gradle make sure you are pointing to the right place. My example:

1.在你的settings.gradle中确保你指向正确的位置。我的例子:

include ':SomeLib'
project (':SomeLib').projectDir = new File('../SomeLib/SomeLib')

2.In your build gradle make sure you are compiling the right Module name

2.在构建gradle中,确保编译正确的模块名称

compile project(':SomeLib')

A good check to see if you are doing things correctly at step 1. Before you go to step 2 make sure the library comes to the Project View. If it comes make sure your actual source code is there. Java classes etc. If you see that stuff then go to step 2. From step 2 you should be good. Let me know how it goes.

在第1步中检查您是否正确执行操作。在转到步骤2之前,请确保库已进入项目视图。如果它来了,请确保您的实际源代码存在。 Java类等。如果你看到那些东西,那么转到第2步。从第2步你应该是好的。让我知道事情的后续。

To be exact this is your example: settings.gradle

确切地说,这是你的例子:settings.gradle

include ':CanvasView'
project (':CanvasView').projectDir = new File('../CanvasView/CanvasView')

build.gradle

compile project(':CanvasView')