Android studio: start project from command line - android

I have read a helpfull tread however there is some things that are missing. I can create project from command line
android create project --gradle --gradle-version 0.12.2 \
--package com.test.test \
--activity TestActivity \
--target 1 \
--path AutoAndroidApp \
However, this does not create an identical structure as if I would create a project with the android studio. For example from GUI application is put in app folder, also there is build forlder and other differences.
Is there a way to actually reproduce the creation of the project from a command line?

Related

create android project with gradle from command line deprecated?

I am trying to create android project with gradle from command line using this command:
android create project \
--target android-23 \
--name HelloWorld \
--path HelloWorld/ \
--activity MainActivity \
--package com.example.helloworld \
--gradle \
--gradle-version 1.3.0
Project structure was successfully generated but when I try to run gradlew assembleDebug I get:
A problem occurred evaluating root project 'HelloWorld'.
> Could not create plugin of type 'AppPlugin'.
I was traversing google for half of day and finally I found that usage of gradle in android create project is (probably) deprecated:
https://code.google.com/p/android/issues/detail?id=160032
Are there any supported methods (that are clean, no hacks) to achieve the goal (in command line)?
As instructed here:
http://eqdn.tech/android-development-on-the-command-line/
You can still use "android create project", but will need to adjust the results manually a little bit afterwards. Essentially changing in gradle/wrapper/gradle-wrapper.properties this:
distributionUrl=http://services.gradle.org/distributions/gradle-1.12-all.zip
To this:
distributionUrl=http://services.gradle.org/distributions/gradle-2.2.1-all.zip
And changing "runProguard false" to "minifyEnabled true" in build.gradle.

How to create an Android Studio module in command line?

I'm trying to create a Bash script to automate the creation of some projects and modules to be used by Android Studio later. However, I can only find how to create projects using the command line, not modules:
android create project --gradle --gradle-version 1.5.0 --target "${BASE_API}" --name "${PROJECT_NAME}" --path "${PROJECT_NAME}" --activity DummyActivity --package it.doesnt.matter
How can I create a module inside the project created above using a Bash command?
A module is mostly just a directory of files. So:
Create a directory (mkdir yourModule)
Put whatever files you want in this directory, such as build.gradle
Script a solution to edit the settings.gradle file and add your module to the list of modules

Creating a project from the terminal

I am experimenting with creating an Android project from the terminal and I have ran into an error, that I dont understand.
Using the Android development website I navigated to the android/tools directory and entered:
android create project \
> target 2 \
> name terminalTest \
> path ./terminalTest \
> activity terminalTestActivity \
But when I enter the next line:
> package com.android.terminalTest
I receive this error:
Error: Argument 'com.android.terminalTest' is not recognized.
Compared to the information on the android development site:
android create project \
--target 1 \
--name MyAndroidApp \
--path ./MyAndroidAppProject \
--activity MyAndroidAppActivity \
--package com.example.myandroid
They look identical(except for the target of course), what am I doing wrong?
You probably don't have the tools directory or the current directory in your path. You could try ./android from the tools directory or jusr add it to your path.

android jrtplib

jni/jrtplib/include/jrtplib3/rtpsessionsources.h:50: error: non-static reference member 'jrtplib::RTPSession& jrtplib::RTPSessionSources::rtpsession', can't use default assignment operator
link to rtpsessionsource.h
http://research.edm.uhasselt.be/jori/jrtplib/documentation/rtpsessionsources_8h_source.html
anyone, please help me.
All depends on how you wanna to build jrtplib
I see 3 options here
use existing build script from https://github.com/jimjh/JRTPLib-for-Android
because jrtplib based on cmake build system, you can use https://github.com/taka-no-me/android-cmake
write own Android.mk
Personally I used second option and my build script looks like this
#!/bin/bash
LIB=jrtplib-3.9.1
BUILD=$(PWD)/build
CMAKE_TOOLCHAIN=$(PWD)/android-cmake
BUILD_TYPE=Debug
mkdir -p $BUILD/armeabi-v7a
cd $BUILD/armeabi-v7a
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN/android.toolchain.cmake \
-DANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DANDROID_ABI="armeabi-v7a with NEON" \
-DJRTPLIB_COMPILE_STATIC=ON \
$LIB
cmake --build .
cd $ROOT
mkdir -p build/x86
cd $BUILD/x86
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN/android.toolchain.cmake \
-DANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DANDROID_ABI="x86" \
-DJRTPLIB_COMPILE_STATIC=ON \
$LIB
cmake --build .
PS I have build without jthread support

Compile android project to apk without eclipse

What I have done is I have taken the class-files from my eclipse project and run them trough an optimizer/obfuscator. So I now have optimized class-files that I want to get in the form of an apk so I can sign and publish it. However, I am lost on how to do this. I guess I cant just copy them into the bin-folder of my eclipse-project, because eclipse would just overwrite them with a new compilation when I try to export a signed apk. So how do I create an apk from these class-files?
you can try to put them in bin/classes and then use "ant" command to build your application
cd /path/to/my/app
ant release
it will ask you every time for your private key to sign the app, it can be configured to auto-sign by editing "build.properties" file:
key.store=release.keystore
key.alias=release
key.store.password=my_key_password
key.alias.password=my_key_password
you can also investigate Android SDK, find the ANT build scripts it actually uses, and insert your custom obfuscator/optimizer call in middle of build process.
Here's an example:
android create project \
--target 1 \
--name MyAndroidApp \
--path ./MyAndroidAppProject \
--activity MyAndroidAppActivity \
--package com.example.myandroid

Categories

Resources