I have a React-Native App that uses a video player component (react-native-video).
I've had to extend this project for Android to include the ability to load assets from an expansion file so this involved including the android.vending.expansion.zipfile project in the /java/com/ folder of the video project.
The video project sits under my main project via the settings.gradle:
include ':RCTVideo', ':app'
project(':RCTVideo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')
and build.gradle file:
compile project(':RCTVideo')
I now realise that I will have to add this same functionality to my separate audio component which also sits under my main project in the same way the video component does.
Rather than be re-apply the same project android.vending.expansion.zipfile to my audio component, can I just apply it to my main react-native android project and reference it in the sub-project??!
I'm a little baffled.
If I understand the issue, then you can simply create a separate module called zipfile that contains the android.vending.expansion.zipfile source. Then just include this module in each app or module as needed:
compile project(':zipfile')
Related
I'm hoping to modularize an Android project so it will be easy to maintain in future use. I want to know whether its possible or not, to make an Android project used as a module within another Android project?
For example, let's say in my main android project I have three buttons for login, signup, forget password. and I have three separate projects for login, signup and forget password with their own views, activities and libraries. How can I use these separate android projects in the main Android project so when I click any of the three options in the main activity view so it will load the relevant view from those three module projects? (click the login button in the main view and load login view from the separate login project activities). I have tried to fiddle with build files and library module importing but couldn't do it. help me with saying if this approach is possible or not? if possible how to achieve it?
settings.gradle in root project include each project.
include ':loginApp'
include ':signupApp'
include ':resetpasswordApp'
project(':loginApp').projectDir = file('path/to/LoginApp')
project(':signupApp').projectDir = file('path/to/SignupApp')
project(':resetpasswordApp').projectDir = file('path/to/ResetpasswordApp')
build.gradle Of main module
implementation project(':loginApp')
implementation project(':signupApp')
implementation project(':resetpasswordApp')
Yes, it's possible.
Your current project is basically a module too. See the app folder.
An easy way is to create a new module (android library) with a different name from the current one which by default is app. Let's call it bigapp. This module will have all properties just like your app and you can select to run it from the debug configuration too.
Go to settings.gradle and ensure the file reads include ':app', ':bigapp'
To use the bigapp and call its functions, import it in your dependency. This will be the build.gradle file of the app module.
dependencies {
implementation project(":bigapp")
}
Lets now start the MainActivity from our app module
startActivity(new Intent(this, com.lucemanb.bigapp.MainActivity.class));
You can also import it at the top and simply call the MainActivity
import com.lucemanb.bigapp.MainActivity;
---
private void startActivity(){
startActivity(new Intent(this, MainActivity.class));
}
I have an Android app but require to create two Different copies of it with different package names. The reason for wanting two package names is that I want to upload them to two different Stores which requires the developer to provide a different package name.
To simplify the update process and fixing the issues I thought of dividing my code to different libraries.
I have now created an android library and now want to upload it so that I can simply use the library in my projects by simply adding the line compile com.adc.aaa...
But I do not want those library to be accessible to other developers either directly of maybe through google Search. Is it possible to achieve this?
These are few links which I have visited regarding this matter
1) https://inthecheesefactory.com/blog/how-to-upload-library-to-jcenter-maven-central-as-dependency/en
2) https://mayojava.github.io/android/library/creating-and-distributing-your-own-android-library/
Can anyone please help.
Suposing your module in android studio is called "library" you can simply add the module to your app project locally without the need to upload it to bitray.
You can add a local module as a depedency to your project using AS or manually:
1) Using AS:
Go to File -> Project structure. Click on the app module and then depedencies, click on the plus sign and then choose 3 - Module Dependency. If you library is in the same folder as your app it'll show up there. Just select it and it will be added as a depedency like the other compile dependencies.
2) Manually
In your settings.gradle file add:
include ':app', ':library'
In your app leve build.gradle:
implementation project(':library')
If you library module is somewhere else you can inport it to your project using:
File -> New-> Import Module
I am working with android studio attempting to implement the following github within my own application
https://github.com/jhansireddy/AndroidScannerDemo
When following the instructions I add the following line to the gradle
compile project(':scanlibrary')
After adding the above i then sync the gradle and the whole project structure changes, to the point where i no longer recognise it
Original Project Structure
New Project Structure
If you havnt gathered i am fairly new to the whole android programming thing
One thought i had was that the git project uses OpenCV and it was related to this, however i have not manually installed OpenCV
You have to import scan library to bring project structure to normal. Follow these steps:
1 - Download zip from this link.
2 - Extract it and copy location of scanlibrary project present inside ScanDemoExample. In my case it is like (D:\Amrit\AndroidScannerDemo-master\AndroidScannerDemo-master\ScanDemoExample\scanlibrary).
3 - Now come back to Android Studio, select
File -> New -> Import Module
and paste copied location path from previous step in source directory which will result in module name :scanlibrary. Click on Finish to close the dialog.
4 - Now your project structure will look like image below. (You can view it by selecting File -> Project Structure).
5 - Don't forget to add dependency
compile project(':scanlibrary')
inside build.gradle file.
6 - Now your library is ready to use with your project. In case you are facing any errors try cleaning & rebuilding your project. And more often errors are import problem so try including these imports :
import com.scanlibrary.ScanActivity;
import com.scanlibrary.ScanConstants;
where ScanActivity & ScanConstants are classes present inside scanlibrary.
Let me know if you have any doubts. Happy coding!
add this depenedency in build.gradle
implementation 'com.github.neutrinosplatform:scanlibrary:3.3'
and add maven in repositories
maven { url 'https://jitpack.io' }
I need to have access to some android classes in a non-android project (just java project) in Eclipse.
What I actually need to do:
Class c = Class.forName("android.widget.Button");
Obviously I get a java.lang.ClassNotFoundException: android.widget.Button
Can I do what I want to do?
do not ad Android Classpath Container in eclipse , instead add individual android.jar..its recommended to add the highest android version and than create a local.properties file to store the location for your build script.
I have a problem when trying to reuse a project class and resources, I always get a ClassNotFoundException. I dont know what I'm doing wrong.
The easier steps for reproduce my problem is create this two projects:
MyLibrary project:
Creating a example launcher activity ("Activity1") and in properties/Android
section mark as librayy
MyProject project:
It is just an empty project (no classes), in Java Build Path\Projects tag add the
project "MyLibrary" and declare in the manifest that it MAIN & LAUNCHER activity
is "Activity1"
Press play and there you have the ClassNotFoundException.
My target is inherit a whole project for making a free version from a paid version and keeping the common code in a single place for keep the maintain easy
Thanks