Can't open ics-openvpn with android studio in mac - android

I clone OpenVPN project in ics-openvpn. And then I install NDK, CMake, swig(4.0.1), update git ... follow doc/README.txt and I open it with Android studio after that.
But when open the project with Android studio I can't see another package in the project.
Here is my result:
How I can fix it to see all the packages and build the project?
Thank you so much!

if you want to devlope on this project follow this steps:
clone the repo
create a new empty project
click on File then new then import module and go to the repo that you download. open it and choose main folder
build the project
open terminal from the android studio and type cd main/cpp or the name that you name it to this module and download this sub modules :
git submodule add https://github.com/schwabe/openvpn.git
git submodule add
https://github.com/schwabe/platform_external_openssl.git
git submodule add https://github.com/ARMmbed/mbedtls.git
git submodule add https://github.com/schwabe/openvpn3.git
git submodule add https://github.com/lz4/lz4.git
git submodule add https://github.com/chriskohlhoff/asio.git
run this commands on terminal :
git submodule init
git submodule update
go to build.gradle for openvpn module and change the following :
id("com.android.application") to id("com.android.library")
copy this snipt of code that exist in build.gradle for the library and paste it in your build.gradle inside android script :
flavorDimensions("implementation")
productFlavors {
create("ui") {
setDimension("implementation")
buildConfigField("boolean", "openvpn3", "true")
}
create("skeleton") {
setDimension("implementation")
buildConfigField("boolean", "openvpn3", "false")
}
}
add the module in the dependency in your build.gradle :
implementation project(path: ':your-module-name')
sync the project and it is done :-)
NOTE: if you can not see the module files click on the gradle on the right of android studio and left-click on the openvpn module and choose refresh Gradle project.
I hope it can help someone.

Related

Project with path ':expo-modules-core' could not be found in expo module

I have created an expo module using yarn create expo-module according to the documentation
When I open android folder of the module in Android Studio and run gradle sync, it produces an error:
Project with path ':expo-modules-core' could not be found in root project 'android'
Gradle script uses project(":expo-modules-core"). expo-modules-core is located in node_modules directory, but the expo-module yarn template doesn't connect to it in any way.
React native plugins on the other hand explicitly specify the location of com.facebook.react:react-native inside node_modules in gradle:
repositories {
maven {
url("$rootDir/../../node_modules/react-native/android")
}
}
dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules
}
The same doesn't work for expo-modules-core because it doesn't contain maven-metadata
So, the question is how to add a dependency to expo-modules-core?
You should link your expo-module to the project using yarn workspaces, after this, you can open the android folder of the workspaces which uses your expo-module as dependency in android studio. The gradle sync will pass and you will see all the expo modules including yours in the project view.

compile apk using external library

Im trying to compile an apk from nextcloud using an external library.
Im following the next steps:
git clone https://github.com/nextcloud/android.git
git clone -b FixAssembleTimeout https://github.com/minfaer/android-library.git
cd android-library
git checkout
cd ../android
git checkout
then the step 5 from https://github.com/nextcloud/android/blob/master/SETUP.md
this is my settings.gradle in nextcloud folder
rootProject.name = 'Nextcloud'
include ':app'
includeBuild('C:\\nextcloud\\android-library') {
dependencySubstitution {
substitute module('com.github.nextcloud:android-library') using project(':android-library')
}
}
But after I click on sync project with gradle files, I get the following error:
Project with path ':android-library' not found in build 'android-library'.
How can I find the correct path, or what am I missing.
Thanks.

importing an existing JAR or AAR as new project module

how to import JAR or AAR package as new project module in A new Android Studio Arctic Fox | 2020.3.1 Canary 9 ?
please let me know.
This works on Android Studio Arctic Fox Beta 02
Step 1 : Navigate to, File -> Project Structure. You can also press Ctrl+Alt+Shift+S
You will see a window just like below.
Step 2 : Click On app module as shown in image
Step 3 : Click on + icon as marked in image
Step 4 : You will see option to select jar/aar dependency. Click on it
You will see another window just like above asking you to specify path. Specify the path in which you kept the aar/jar file and hit Ok.
That should work
You can directly implement using JAR/ARR file path.
implementation files('/File Path/file.aar')
For Android Studio Bumblebee, original answer given here
I have followed steps suggested by the Android developer site:
Copy .aar file into the libs folder of the app
File -> Project Structure... -> Dependencies
Click on "+" icon and select JR/AAR Dependency and select app module
Add .aar file path in step 1.
Check your app’s build.gradle file to confirm a declaration.
Step 1: Put your aar file in the libs folder. And let’s take the file name is supernover.aar as an example.
Step 2: Put the following code in your Project level
build.gradle file,
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
and in the app level module write the below code,
dependencies {
Implementation(name:'supernover', ext:'aar')
}
Step 3: Then Click sync project with Gradle files.
If everything is working fine, then you will see library entry is made in build ->intermediates -> exploded-aar.
In my opinion, the best way to do this is to deploy the jar/aar to a local maven repository. if you install maven, you can use the mavenLocal() repository in gradle and read from there as with any other repo, regardless of the IDE you are using. All versions of Android Studio will work, all version of IntelliJ will work, VSCode will work, the command line will work, etc. Another advantage is, you'll be able to swap versions of the library as you do with all the others, just change the version in gradle (after deploying the new one), and will work for all your projects. Putting jars/aars manually into a project is just a bad practice, and reaaally outdated to top.
Once you installed maven, type this in your terminal:
mvn install:install-file -Dfile=d:\mylibrary-{version}.aar -DgroupId=com.example -DartifactId=mylibrary -Dversion={version} -Dpackaging=aar
Where you swap aar and jar depending on the type. The package name, group ID and library name are up to you, anything will work. I would use the library's package and name, and version 1.0 if you don`t have a version.
Here's an example link. Is old, but the process is the same. mvn install, then consume from mavenLocal().
For anyone in search of a solution still.
Create a new android Application project.
Convert new project into a standalone Library module.
Add maven-publish plugin to the module-level build.gradle
Connect your project to your Github repository (or create a new one).
In the module-level build.gradle, implement the Github Packages authentication flow. I'm using 'zuko' as an example - replace every instance of that name with your Github login.
android {
...
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/zuko/[git-repository]")
credentials {
username = 'zuko'
password = 'token' // this is a Git Personal Access Token
}
}
}
publications {
release(MavenPublication) {
groupId 'com.zuko.libraries'
artifactId 'choose-a-name'
version '1.0.0'
artifact("$buildDir/ogury-mediation-mopub-5.2.0.aar")
// you can actually put the artifact anywhere you want.
// This is the location of where you place your .aar file
}
}
}
...
}
If everything is connected properly, save your work, and run the the task: ./gradlew publish. The error logs are straightforward so just defer to the instructions and Google for more assistance.
To install a successfully published package into your desired project, use the same auth procedure for publishing.repositories, you don't need the second half, publishing.publications.
example: implementation 'com.zuko.libraries:choose-a-name:1.0.0'
You could configure a repository in you buildscript that looks for dependencies in a local directory
Use this to register a local directory as repository in your app module's build.gradle where libs is a directory under app module (<project>/app/libs/)
buildscript {
repositories {
flatDir { dirs 'libs' }
}
}
then declare your dependencies from the local file tree you registered earlier
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
This will include all jar/aar artifacts present under libs directory to be included in your module's dependencies.
PS: Local jar/aar artifacts will expect any transitive dependencies to be on the classpath unless they are fat-jars (package all transitive dependencies within the artifact), so these need to be added explicitly as dependencies.

Git submodules in existing gradle project

I have some application which has few modules that i want to to replace in submodule.
Can I do that in the current project. Create new repo with these modules.
Yes you can achieve this in following way :
Say your main project is in X_REPO\Project\app
Move your module in a separate repo say Y_REPO
Then add Y REPO as submodule in X_REPO\Module1
Now make the following changes in
settings.gradle
include ':Module1'
project(':Module1').projectDir=new File('../Module1/module_directory')
X_REPO\Project\app\build.gradle
compile project(':Module1')
Since Android Studio uses same gradle build system, same can be achieved in Android Project as well.

Adding gradle dependency from git project

I am trying to add this project to my gradle project in Android studio. I tried using Gradle git plugin as described here but Gradle says it can not find those files even though i placed folders inside app folder in my project. I added in dependencies in gradle.build file to include project in build but no luck, it just says project does not exist. Does anyone know good tutorial or have any suggestion about this?
You could register the repository as a submodule like this
$ git submodule add my_sub_project_git_url my-sub-project
Then include the project in your settings.gradle file which should look like this
include ':my-app', ':my-sub-project'
Finally, compile the project as a dependency in your application build.gradle file like this
dependencies {
compile project(':my-sub-project')
}
Then, when cloning your project, you will only have to add the option --recursive to make git automatically clone the root repository, and all its submodules.
git clone --recursive my_sub_project_git_url
I hope it helps.

Categories

Resources