I'm trying to compile boringssl libraries so that I could use it in an Android project (building on Ubuntu 18.04). I'm following the build steps from this link.
amy#test-ubuntu18:~/android_test/boringssl/build$ cmake -DANDROID_ABI=arm64-v8a -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=21 -GNinja ..
CMake Error at CMakeLists.txt:14 (enable_language):
The CMAKE_C_COMPILER:
/home/amy/android_test/android-ndk-r21-beta2/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
is not a full path to an existing compiler tool.
Here's my env set up:
amy#test-ubuntu18:~/android_test/boringssl/build$ echo $ANDROID_NDK
/home/amy/android_test/android-ndk-r21-beta2
amy#test-ubuntu18:~/android_test/boringssl/build$ echo $CC
/usr/bin/gcc
amy#test-ubuntu18:~/android_test/boringssl/build$ echo $CXX
/usr/bin/g++
And the tools do exist in my /usr/bin
amy#test-ubuntu18:~/android_test/boringssl/build$ ls -l /usr/bin/*g{cc,++}*
-rwxr-xr-x 1 root root 428 May 7 2006 /usr/bin/c89-gcc
-rwxr-xr-x 1 root root 454 Apr 11 2011 /usr/bin/c99-gcc
lrwxrwxrwx 1 root root 27 May 16 2018 /usr/bin/clang++ -> ../lib/llvm-6.0/bin/clang++
lrwxrwxrwx 1 root root 27 Apr 5 2018 /usr/bin/clang++-6.0 -> ../lib/llvm-6.0/bin/clang++
lrwxrwxrwx 1 root root 25 Apr 10 2019 /usr/bin/clang++-8 -> ../lib/llvm-8/bin/clang++
lrwxrwxrwx 1 root root 5 May 20 2019 /usr/bin/g++ -> g++-7
lrwxrwxrwx 1 root root 22 May 8 2019 /usr/bin/g++-7 -> x86_64-linux-gnu-g++-7
lrwxrwxrwx 1 root root 5 May 20 2019 /usr/bin/gcc -> gcc-7
lrwxrwxrwx 1 root root 22 May 8 2019 /usr/bin/gcc-7 -> x86_64-linux-gnu-gcc-7
lrwxrwxrwx 1 root root 8 May 20 2019 /usr/bin/gcc-ar -> gcc-ar-7
lrwxrwxrwx 1 root root 25 May 8 2019 /usr/bin/gcc-ar-7 -> x86_64-linux-gnu-gcc-ar-7
lrwxrwxrwx 1 root root 8 May 20 2019 /usr/bin/gcc-nm -> gcc-nm-7
lrwxrwxrwx 1 root root 25 May 8 2019 /usr/bin/gcc-nm-7 -> x86_64-linux-gnu-gcc-nm-7
lrwxrwxrwx 1 root root 12 May 20 2019 /usr/bin/gcc-ranlib -> gcc-ranlib-7
lrwxrwxrwx 1 root root 29 May 8 2019 /usr/bin/gcc-ranlib-7 -> x86_64-linux-gnu-gcc-ranlib-7
lrwxrwxrwx 1 root root 5 May 20 2019 /usr/bin/x86_64-linux-gnu-g++ -> g++-7
-rwxr-xr-x 1 root root 1010624 May 8 2019 /usr/bin/x86_64-linux-gnu-g++-7
lrwxrwxrwx 1 root root 5 May 20 2019 /usr/bin/x86_64-linux-gnu-gcc -> gcc-7
-rwxr-xr-x 1 root root 1010624 May 8 2019 /usr/bin/x86_64-linux-gnu-gcc-7
lrwxrwxrwx 1 root root 8 May 20 2019 /usr/bin/x86_64-linux-gnu-gcc-ar -> gcc-ar-7
-rwxr-xr-x 1 root root 27104 May 8 2019 /usr/bin/x86_64-linux-gnu-gcc-ar-7
lrwxrwxrwx 1 root root 8 May 20 2019 /usr/bin/x86_64-linux-gnu-gcc-nm -> gcc-nm-7
-rwxr-xr-x 1 root root 27104 May 8 2019 /usr/bin/x86_64-linux-gnu-gcc-nm-7
lrwxrwxrwx 1 root root 12 May 20 2019 /usr/bin/x86_64-linux-gnu-gcc-ranlib -> gcc-ranlib-7
-rwxr-xr-x 1 root root 27104 May 8 2019 /usr/bin/x86_64-linux-gnu-gcc-ranlib-7
Versions of tools are listed below:
amy#test-ubuntu18:~/android_test/boringssl/build$ ninja --version
1.8.2
amy#test-ubuntu18:~/android_test/boringssl/build$ cmake --version
cmake version 3.15.2
Tried the suggestions mentioned in this issue, but of no use.
The error says "/home/amy/android_test/android-ndk-r21-beta2/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" is not full path, so I checked what's in the path (I don't see the "linux-x86_64" listed in there):
$ls -l /home/amy/android_test/android-ndk-r21-beta2/toolchains/llvm/prebuilt/
drwxrwxr-x 13 amy amy 4096 Jan 3 15:35 windows-x86_64
Related
I am automating the Android SDK installation via a Python script and I can't figure out where the skins folder is coming from.
It seems the folder is being created, inside the SDK location, when an emulator is created via AVD Manager UI (when it is launched from Android Studio):
ll ~/Library/android/sdk
total 24
drwxr-xr-x 17 user staff 544 Aug 14 20:33 ./
drwxr-xr-x 6 user staff 192 Dec 7 2017 ../
-rw-r--r-- 1 user staff 16 Aug 14 19:35 .knownPackages
drwxr-xr-x 7 user staff 224 Jul 17 14:56 build-tools/
drwxr-xr-x 51 user staff 1632 Jan 11 2018 docs/
drwxr-xr-x 18 user staff 576 Jul 22 01:26 emulator/
drwxr-xr-x 6 user staff 192 Oct 9 2017 extras/
drwxr-xr-x 3 user staff 96 Jan 2 2018 fonts/ # <- Where is it coming from?
drwxr-xr-x 8 user staff 256 Jul 25 18:28 licenses/
drwxr-xr-x 3 user staff 96 Oct 9 2017 patcher/
drwxr-xr-x 19 user staff 608 Jun 6 17:30 platform-tools/
drwxr-xr-x 9 user staff 288 Aug 12 19:55 platforms/
drwxr-xr-x 26 user staff 832 Apr 25 10:53 skins/ # <- Where is it coming from?
drwxr-xr-x 8 user staff 256 Jan 11 2018 sources/
drwxr-xr-x 8 user staff 256 Aug 3 15:24 system-images/
drwxr-xr-x 14 user staff 448 Oct 9 2017 tools/
Questions:
Where are the fonts and skins folder coming from?
Is there a way to download them from an URL?
Is there any avdmanager command to force it to be installed?
Here is my python script to automate the installation:
#!/usr/bin/env python
import os
import urllib
# Android resource file
androidrc = os.path.join(os.environ['HOME'], '.androidrc')
if not os.path.exists(androidrc):
with open(androidrc, 'w'):
pass
# Bash resource file (~/.bashrc)
bashrc = os.path.join(os.environ['HOME'], '.bashrc')
# Environment variables needed for android
environment_variables = [
('ANDROID_TEMP_DIR', '/tmp/android'),
('ANDROID_HOME', '$HOME/Library/Android/sdk'),
('ANDROID_SDK_HOME', '$HOME'),
('ANDROID_TOOLS', '$ANDROID_HOME/tools'),
('ANDROID_PLATFORM_TOOLS', '$ANDROID_HOME/platform-tools')]
def humansize(nbytes):
suffixes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
i = 0
while nbytes >= 1024 and i < len(suffixes) - 1:
nbytes /= 1024.
i += 1
f = ('%.2f' % nbytes).rstrip('0').rstrip('.')
return '%s %s' % (f, suffixes[i])
def add_to_bashrc():
with open(bashrc, 'r') as bashrc_r:
if androidrc not in bashrc_r.read():
print("Including %s to %s" % (androidrc, bashrc))
with open(bashrc, 'a') as bashrc_a:
bashrc_a.write('''
# Adding environment for android
# include %s if it exists
if [ -f "%s" ]; then
. "%s"
fi
''' % (androidrc, androidrc, androidrc))
def set_environment_variables():
print("Creating/updating the %s resource file" % androidrc)
with open(androidrc, 'w') as new_file:
value = '''
# Setting environment for android
%s
export PATH=$ANDROID_PLATFORM_TOOLS:$ANDROID_TOOLS:$ANDROID_TOOLS/bin:$PATH
''' % '\n'.join(["export %s=%s" % (env[0], env[1]) for env in environment_variables])
new_file.write(value)
# Show content
os.system('cat %s' % androidrc)
def install_android_sdk_tools():
android_temp_dir = os.environ['ANDROID_TEMP_DIR']
zip_file = os.path.join(android_temp_dir, "sdk-tools.zip")
# Create android temp dir if doesn't exist
if not os.path.exists(android_temp_dir):
os.makedirs(android_temp_dir)
if not os.path.exists(zip_file):
# Download SDK tools zip file
url = "https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip"
print("Downloading sdk tools from: \n\t%s" % url)
f = urllib.urlopen(url)
with open(zip_file, "wb") as zipFile:
zipFile.write(f.read())
print("SDK tools downloaded to: \n\t%s [%s]" % (zip_file, humansize(os.path.getsize(zip_file))))
# create android home if doesn't exists
android_home = os.environ['ANDROID_HOME']
if not os.path.exists(android_home):
os.makedirs(android_home)
# unzip SDK tools zip file into android home
os.system('unzip -o %s -d %s' % (zip_file, android_home))
print("\n%s content:\n" % android_home)
os.system('ls -la %s' % android_home)
def install_android_platform_tools():
print("\nInstalling 'platform-tools'...\n")
os.system('echo "y\n" | sdkmanager "platform-tools"')
def install_android_platforms():
print("\nInstalling platforms 23 to 28...\n")
for i in range(23, 28):
print("\nInstalling platforms;android-%s" % i)
os.system('sdkmanager "platforms;android-%s"' % i)
def install_android_system_images():
print("Installing system images 23 to 28...\n")
for i in range(23, 28):
print("\nInstalling system-images;android-%s;google_apis;x86" % i)
os.system('echo "y\n" | sdkmanager --install "system-images;android-%s;google_apis;x86"' % i)
def install_emulator_skins():
print("\nInstalling emulator...\n")
os.system('sdkmanager "emulator"')
print("\nInstalling skins...\n")
android_temp_dir = os.environ['ANDROID_TEMP_DIR']
# For now, I am downloading a pre-zipped file from storage URL
# This is not the desired behavior, but is working for now
skins_url = "https://www.example.com/skins.zip"
print("Downloading skins from: \n\t%s" % skins_url)
f = urllib.urlopen(skins_url)
zip_file = os.path.join(android_temp_dir, "skins.zip")
with open(zip_file, "wb") as zipFile:
zipFile.write(f.read())
print("Skins downloaded to: \n\t%s [%s]" % (zip_file, humansize(os.path.getsize(zip_file))))
android_home = os.environ['ANDROID_HOME']
# unzip skin zip file into android home
os.system('unzip -o %s -d %s' % (zip_file, android_home))
def accept_licenses():
print("\nAccepting all licenses...\n")
os.system('echo "yes\n" | sdkmanager --licenses')
if __name__ == "__main__":
# 1. Set environment variables
set_environment_variables()
add_to_bashrc()
# 2. Install SDK tools
install_android_sdk_tools()
# 3. Install platform-tools
install_android_platform_tools()
# 4. Install android platforms
install_android_platforms()
# 5. Install system images
install_android_system_images()
# 6. Install skins
install_emulator_skins() # <- This is where I need help
# 7. Accept all licenses
accept_licenses()
How do I get the skins from Google's repository?
To clear up some disk space I moved my mp3 collection from internal to external storage. My device is rooted and I was su at the time.
The files can be seen (and played) from the File Manager, but none of my music players see them.
What looked interesting was the file permissions after moving. Here's a file still on internal storage that wasn't moved.
root#kltetmo:/data/media/0/Download/mp3 # ll
-rw-rw-r-- 1 1023 1023 6730901 Aug 25 16:03 fatamix_upd_start_20160824(2).mp3
root#kltetmo:/data/media/0/Download/mp3 #
And here are a couple files that were moved to external storage:
root#kltetmo:/storage/sdcard1/Music/Bat for Lashes/Fur and Gold # ll
-rwxrwx--- 1 root 1028 5887321 Jul 16 2015 01 - Horse And I.mp3
-rwxrwx--- 1 root 1028 5894753 Jul 16 2015 04 - What's A Girl To Do_.mp3
Moving them to external storage appears to have changed permissions. Unfortunately, chmod is not affecting the actual file permissions:
root#kltetmo:/storage/sdcard1/Music/Bat for Lashes/Fur and Gold # ll
-rwxrwx--- 1 root 1028 5887321 Jul 16 2015 01 - Horse And I.mp3
-rwxrwx--- 1 root 1028 5894753 Jul 16 2015 04 - What's A Girl To Do_.mp3
root#kltetmo:/storage/sdcard1/Music/Bat for Lashes/Fur and Gold # chmod 664 01\ -\ Horse\ And\ I.mp3
root#kltetmo:/storage/sdcard1/Music/Bat for Lashes/Fur and Gold # ll
-rwxrwx--- 1 root 1028 5887321 Jul 16 2015 01 - Horse And I.mp3
-rwxrwx--- 1 root 1028 5894753 Jul 16 2015 04 - What's A Girl To Do_.mp3
I tried moving the file back to internal storage to change permissions there. This worked until I moved the file back to external storage.. moving it definitely changed permissions to 770.
root#kltetmo:/data/media/0/Music # ll
-rwxrwx--- 1 root 1028 5887321 Nov 14 18:18 batforlashes.mp3
root#kltetmo:/data/media/0/Music # chmod 644 batforlashes.mp3
root#kltetmo:/data/media/0/Music # ll
-rw-r--r-- 1 root 1028 5887321 Nov 14 18:18 batforlashes.mp3
root#kltetmo:/data/media/0/Music # mv batforlashes.mp3 /storage/sd
sdcard0/ sdcard1/
forlashes.mp3 /storage/sdcard1/Music/Bat\ for\ Lashes/Fur\ and\ Gold/ <
root#kltetmo:/data/media/0/Music # ll
root#kltetmo:/data/media/0/Music # ll /storage/sdcard1/Music/Bat\ for\ Lashes/Fur\ and\ Gold/
-rwxrwx--- 1 root 1028 5887321 Jul 16 2015 01 - Horse And I.mp3
-rwxrwx--- 1 root 1028 5894753 Jul 16 2015 04 - What's A Girl To Do_.mp3
-rwxrwx--- 1 root 1028 5887321 Nov 14 18:18 batforlashes.mp3
root#kltetmo:/data/media/0/Music #
What do I need to do to reset permissions so these files can be seen and played from my default music app?
Android media player apps do not scan the file system to get the list of available media files - they get the list from an internal database. You need to send the ACTION_MEDIA_SCANNER_SCAN_FILE intent to force rescan of the folder where the files were moved to for them to become visible to the player apps.
I am trying to set up Continuous Integration (CI) in Bitbucket Pipelines for Android.
I have created a sample blank activity using Android Studio 2.1.1.
With Pipelines I'm using the uber/android-build-environment Docker container which creates the environment nicely. Here is my bitbucket-pipelines.yml
image: uber/android-build-environment:latest
pipelines:
default:
- step:
script:
- echo y | android update sdk --filter "extra-android-m2repository" --no-ui -a # Grab the Android Support Repo which isn't included in the container
- ./gradlew assembleDebug
Some changes are needed since uber/android-build-environment is expecting to be run like so:
docker run -i -v $PWD:/project -t uber/android-build-environment /bin/bash /project/ci/build.sh
For example, the source is not copied to the volume /project but instead Pipelines copies the contents of the Bitbucket repo to the working directory of the container at:
/opt/atlassian/bitbucketci/agent/build
And when ./gradlew assembleDebug is run I get the following error:
...
FAILURE: Build failed with an exception.
* What went wrong:
Could not create service of type TaskArtifactStateCacheAccess using TaskExecutionServices.createCacheAccess().
> Failed to create parent directory '/opt/atlassian/bitbucketci/agent/build/.gradle' when creating directory '/opt/atlassian/bitbucketci/agent/build/.gradle/2.10/taskArtifacts'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 56.449 secs
Running ls -al in the working directory gives:
ls -al
total 52
drwxr-xr-x 5 root root 4096 May 31 22:33 .
drwxr-xr-x 3 root root 4096 May 31 22:43 ..
drwxr-xr-x 3 root root 4096 May 31 22:33 app
-rw-r--r-- 1 root root 462 May 31 22:33 bitbucket-pipelines.yml
-rw-r--r-- 1 root root 498 May 31 22:33 build.gradle
drwxr-xr-x 8 root root 4096 May 31 22:33 .git
-rw-r--r-- 1 root root 387 May 31 22:33 .gitignore
drwxr-xr-x 3 root root 4096 May 31 22:33 gradle
-rw-r--r-- 1 root root 855 May 31 22:33 gradle.properties
-rwxr-xr-x 1 root root 4971 May 31 22:33 gradlew
-rw-r--r-- 1 root root 2314 May 31 22:33 gradlew.bat
-rw-r--r-- 1 root root 15 May 31 22:33 settings.gradle
It's a bug in their system , I report it(issue url, it's quite long) to them and they have fixed it (fix url).I have tested on my project and it successfully build.Try to build your project now and good luck.
It looks like uber/android-build-environment is not supported anymore.
I ended up using javiersantos/android-ci instead which works perfectly from scratch.
Just add the following content to bitbucket-pipeline.yml:
image: javiersantos/android-ci:27.0.3
pipelines:
default:
- step:
script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- chmod +x ./gradlew
- ./gradlew assembleDebug
Could you symlink your project from /opt/atlassian/bitbucketci/agent/build to /project from within the container? ln -s /opt/atlassian/bitbucketci/agent/build /project is the command you'll need.
or alternatively copy the files to the new path?
I have no experience with android development, so YMMV :)
bit of a beginner to all this. But this year we have been asked to make a Android Tic Tac Toe game, and I've just finished it, but sent it off to my lecturer to check out a simple problem I was having.
However he says he cannot open it as it is not recognised as a project and it is missing the .project file.
When looking back over my old projects, not a single one of them has a .project file in it (a least 30 project), however they all open absolutely fine on my Mac, and the PC's in uni when I copy them onto my USB and import them into Eclipse.
The deadline is monday and I'm getting a bit worried. I don't mind making a new project from scratch and copying my code into it. But I don't see how it will help seeing as none of my previous projects have been made with them.
Any help will be GREATLY appreciated.
Thanks, Will
A piece of information you may be missing is that files prefixed with a period (.) are hidden files on Unix-based OS's. Therefore you will not see them by default in Finder on OSX.
If you open a Terminal, navigate to your project (cd <project-path>) and execute ls -la, they will show up.
Example output:
Justins-iMac:HelloWorld justinjasmann$ ls -la
total 144
drwxr-xr-x 14 justinjasmann staff 476 26 Feb 16:50 .
drwxrwxrwx 10 justinjasmann staff 340 28 Feb 01:12 ..
-rw-r--r-- 1 justinjasmann staff 466 26 Feb 16:51 .classpath
-rw-r--r-- 1 justinjasmann staff 813 26 Feb 16:50 .project
-rw-r--r-- 1 justinjasmann staff 845 26 Feb 16:50 AndroidManifest.xml
drwxr-xr-x 2 justinjasmann staff 68 26 Feb 16:50 assets
drwxr-xr-x 10 justinjasmann staff 340 28 Feb 01:07 bin
drwxr-xr-x 3 justinjasmann staff 102 26 Feb 16:51 gen
-rw-r--r-- 1 justinjasmann staff 51394 26 Feb 16:50 ic_launcher-web.png
drwxr-xr-x 3 justinjasmann staff 102 26 Feb 16:50 libs
-rw-r--r-- 1 justinjasmann staff 781 26 Feb 16:50 proguard-project.txt
-rw-r--r-- 1 justinjasmann staff 563 26 Feb 16:50 project.properties
drwxr-xr-x 14 justinjasmann staff 476 26 Feb 16:50 res
drwxr-xr-x 3 justinjasmann staff 102 26 Feb 16:50 src
Files who's names begin with '.' are Filtered by default in most views. If your project is working fine, you must have a .project file.
My $NDK_HOME folder contains different implementations of the standard library.
qdii#nomada /opt/android-ndk/platforms $ ls -l
total 24
drwxr-xr-x 5 root android 4096 3 déc. 19:18 android-14
drwxr-xr-x 3 root android 4096 30 déc. 18:42 android-3
drwxr-xr-x 3 root android 4096 30 déc. 18:42 android-4
drwxr-xr-x 3 root android 4096 30 déc. 18:42 android-5
drwxr-xr-x 3 root android 4096 30 déc. 18:42 android-8
drwxr-xr-x 5 root android 4096 3 déc. 19:18 android-9
Each one of these different directories contain a version of the standard library. For a custom project that is built without using ndk-build, I would like to know which one to use.
Say my project uses the NDK version 8d, which implementation of the standard library should I use?
As you can see, they're tagged by API level. So you should use the one corresponding to the minimal API level your app is targeting.