Creating a project from the terminal - android

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.

Related

Docker can not find Android SDK and NDK directory

I've created a docker container in order to run my gradle tasks on it.
I'm downloading the sdk inside it, but when I run a task from outside it says that the sdk folder can not be found because it's getting the path I have in the local.properties file of the project. Which is pointing to my machine sdk folder. How can I specify the sdk folder inside the docker image? Thanks.
Docker image build file:
FROM openjdk:8
ENV SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip" \
ANDROID_HOME="/usr/local/android-sdk" \
ANDROID_NDK_HOME="/usr/local/android-sdk/ndk-bundle" \
ANDROID_VERSION=26 \
ANDROID_BUILD_TOOLS_VERSION=26.0.2
# Download Android SDK
RUN mkdir "$ANDROID_HOME" .android \
&& cd "$ANDROID_HOME" \
&& curl -o sdk.zip $SDK_URL \
&& unzip sdk.zip \
&& rm sdk.zip \
&& yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
# add to PATH
ENV PATH ${PATH}:${ANDROID_HOME}
ENV ANDROID_NDK_HOME /usr/local/android-ndk
ENV ANDROID_NDK_VERSION r19
ENV NDK_URL="https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip"
# Download Android NDK
RUN mkdir "$ANDROID_NDK_HOME" \
&& cd "$ANDROID_NDK_HOME" \
&& curl -o ndk.zip $NDK_URL \
&& unzip ndk.zip \
&& rm ndk.zip
# add to PATH
ENV PATH ${PATH}:${ANDROID_NDK_HOME}
# Install Android Build Tool and Libraries
RUN $ANDROID_HOME/tools/bin/sdkmanager --update
RUN $ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
"platforms;android-${ANDROID_VERSION}" \
"platform-tools"
RUN mkdir /application
WORKDIR /application
This is how I run the task:
docker run -it --rm -v "$PWD":/application packsdkandroiddocker.image sh -c "$#" ./gradlew clean
And this is the error I get:
NDK is missing a "platforms" directory. If you are using NDK, verify
the ndk.dir is set to a valid NDK directory. It is currently set to
/Users/adalpari/Library/Android/sdk/ndk-bundle. If you are not using
NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties
to remove this warning.
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':app'.
The SDK directory '/Users/adalpari/Library/Android/sdk' does not exist.
I think you need to remove local.properties file from your root folder as SDK is then searched locally which container cannot access.

Android studio: start project from command line

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?

How to compile Protobuf 2.6.0 for Android on Windows

I'm trying to compile Protobuf 2.6.0 for Android on Windows.
I have to say that I need a staic Protobuf library for using with Qt 5 on Android.
In Cygwin bash I run the next command:
./configure --prefix=c:/Thirdparty/Android/protobuf/build \
--host=arm-linux-androideabi \
--disable-shared \
--enable-cross-compile \
--with-protoc=c:/Thirdparty/bin/protoc \
CC=c:/Thirdparty/Android/NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc.exe \
CXX=c:/Thirdparty/Android/NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-g++.exe \
LDFLAGS=-Lc:/Thirdparty/Android/NDK/platforms/android-5/arch-arm/usr/lib \
CPPFLAGS=-Ic:/Thirdparty/Android/NDK/platforms/android-5/arch-arm/usr/include
But I got the next error:
configure:3474: checking whether the C compiler works
configure:3496: c:/Thirdparty/Android/NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc.exe \
-Ic:/Thirdparty/Android/NDK/platforms/android-5/arch-arm/usr/include \
-Lc:/Thirdparty/Android/NDK/platforms/android-5/arch-arm/usr/lib conftest.c >&5
c:/thirdparty/android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
error: cannot open crtbegin_dynamic.o: No such file or directory
c:/thirdparty/android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe:
error: cannot open crtend_android.o: No such file or directory
collect2.exe: error: ld returned 1 exit status
What should I do else? Thank you.
I found the solution. I had to define --sysroot="", like this:
LDFLAGS="-Lc:/Thirdparty/Android/NDK/platforms/android-5/arch-arm/usr/lib \
--sysroot=c:/Thirdparty/Android/NDK/platforms/android-5/arch-arm"

Why libclcore in directory "host" in android 4.4 source code not update like target?

Now I want to add a function into RenderScript to support a new interface by myself.
I wrote the code and add myFunc.c file into "android-4.4-src/frameworks/rs/driver/runtime/", and modify Android.mk(append myFunc.c to clcore_base_files at line 20):
clcore_base_files := \
rs_allocation.c \
rs_cl.c \
rs_core.c \
rs_element.c \
rs_mesh.c \
rs_matrix.c \
rs_program.c \
rs_sample.c \
rs_sampler.c \
convert.ll \
allocation.ll \
rsClamp.ll \
myFunc.c
Then add myFunc.rsh into "android-4.4-src/frameworks/rs/scriptc/", and include myFunc.rsh in rs_core.rsh which in the same directory:
#include "myFunc.rsh"
And then I rebuild:
$ source build/envsetup.sh
$ lunch sdk-eng
$ make sdk
The weird thing is: libclcore.bc in "out/target/product/generic/system/lib/" is the new version which contains the function I wrote, but the libclcore.bc in "out/host.linux-x86/sdk/androidXXX/build-tools/android-4.4.3.2xxx/renderscript/lib" is the old version.
I want to update the old version in "host" like the one in "target" when rebuild.
Is there some configurations I forgot?
Any suggestions would be appreciated!

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

Categories

Resources