Update: To clarify, I can build the process successfully. The question is about installing the example project directly on a device (though I'm thinking emulator won't work either).
I developed a module about two years ago that allowed bluetooth connectivity on Android. I believe the latest version of the Titanium SDK at the time was around 2.0. I believe the specifics of the module and the example app are irrelevant to this question. I will ask my question first, and then try and explain the steps that I have gone through to lead me to the actual question.
My question is: is something in my environment misconfigured, or is this a bug in the Titanium SDK?
If it is the latter, I am very surprised that I can't find any information about it, since it prevents android modules from installing with ant in the latest SDK.
Information about my build environment:
Mac OS 10.9.5
Titanium Studio 3.3.0.GA
Ti CLI 3.3.0
Android 19
java -version: java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
I am trying to build it now for the latest SDK, 3.3.0 at the time of this writing. I found that when I tried to build (install) with ant, it resulted in the following output:
[exec] [ERROR] /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res/values-v14/themes_base.xml:133: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.
[exec] [ERROR] /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res/values-v14/themes_base.xml:148: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DialogWhenLarge'.
[exec] [ERROR] /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res/values-v14/themes_base.xml:159: error: Error: No resource found that matches the given name: attr 'android:actionBarWidgetTheme'.
[exec] [ERROR] Error generating R.java from manifest
[exec] [ERROR] Build Failed.
BUILD SUCCESSFUL
Total time: 20 seconds
Not only that, but when creating a brand new mobile module project, and building straightaway with ant:
cd proj/android && ant install
The errors are the same. I should also point out that I reformatted not too long ago, so I find it unlikely that I have borked my titanium installation already. Now, from here, I've gotten into the Titanium build scripts to try and figure out what is happening. First, from the Titanium SDK 3.3.0 release notes:
Due to the addition of the appcompat library, there are a number of behavior changes to the application:
...
The target SDK must be set to API level 14 (Android 4.0.x) or higher, or you must have API level 14 or higher installed.
Now in the build output for my project:
[exec] [TRACE] Writing out AndroidManifest.xml
[exec] [DEBUG] /path/to/my/androidsdk/build-tools/17.0.0/aapt package -m -J /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/gen -M /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/AndroidManifest.xml -S /var/folders/x7/h7lgzf1n4nx7fcwr26fdrzxr0000gn/T/mTUYC62ti/testmodule/build/android/res -I /path/to/my/androidsdk/platforms/android-10/android.jar
Note that it's using the tools for android-10 and not android-14+ which is strange considering the relevant bits of my timodule.xml and build.properties:
timodule.xml:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
<tool-api-level>19</tool-api-level><!-- deprecated - see below -->
build.properties:
titanium.platform=/Users/trey/Library/Application Support/Titanium/mobilesdk/osx/3.3.0.GA/android
android.platform=/Users/trey/sdk/android-sdk-macosx/platforms/android-19
google.apis=/Users/trey/sdk/android-sdk-macosx/add-ons/addon-google_apis-google-19
android.ndk=/Users/trey/sdk/android-ndk-r9d
As it turns out, it seems to be only the deprecated element that matters, and not in timodule.xml at all. Build scripts are found at $titanium_sdk/$os/$version/android/
Observation: Setting MIN_API_LEVEL = 19 (or 14) instead of 10 in builder.py fixes the issue. So the build script is ignoring my configuration and using the default. This seems to happen in the init method of the builder class:
temp_tiapp = TiAppXML(self.project_tiappxml)
if temp_tiapp and temp_tiapp.android:
if 'tool-api-level' in temp_tiapp.android:
self.tool_api_level = int(temp_tiapp.android['tool-api-level'])
tool_api_level_explicit = True
This sets the tool_api_level that the build script uses, but in my case it never gets called because there is not tiapp.xml. So I made a tiapp.xml, and put it in my example project. It has the same configs as the timodule.xml. As part of the build process this gets copied along with the rest of the example project into a temp folder that will be used to build and run the project. self.project_tiappxml in the code above is the root of the project. And there is still no tiapp.xml there, because it was copied to the Resources directory with everything else, so tool_api_level always gets set to the default of 10. That is basically as far as I've gotten.
So, again my question: is my configuration wrong, or is this a bug. It seems to me that if it is a bug, then no one would be able to build android modules, best I can tell. So if it's my fault, what have I done to cause it, and how can I fix it.
Update: If you saw my last edit, that was wrong and I'm sorry - my selected SDK for ti was 3.2.3! Fixed that and it creates the new project fine. It also builds. However, installing the example project still results in the same error as above:
[exec] [ERROR] Error generating R.java from manifest
[exec] [ERROR] Build Failed.
I also added a line above the call to aapt, to clarify that these errors occur while trying to write AndroidManifest.xml for the example project.
Its good you are working with 3.3.0, because from this version Android module creation is relatively easy.by viewing your build.properties i think something is missing or you forgot to add completely here it should be something close to :
titanium.platform=/Users/xxxxxx/Library/Application Support/Titanium/mobilesdk/osx/3.3.0.GA/android
android.platform=/Users/xxxxxx/Documents/adt-bundle-mac/sdk/platforms/android-16
google.apis=/Users/xxxxxx/Documents/adt-bundle-mac/sdk/add-ons/addon-google_apis-google-16
android.ndk=/Users/xxxxxx/Documents/android-ndk
but what i would suggest is check the following things as they get missed often:
you should have android-ndk installed and in the path
you must have gperf installed with your system(for mac comes with xcode command line tools)
Followed by running the following command in your terminal:
ti create -p android -t module -d <WORKSPACE_DIR> -n <MODULE_NAME> -u <MODULE_URL> --id <MODULE_ID>
## Sample Command
ti create -p android -t module -d ~/Documents/Sample_Workspace/ -n calc -u http:// --id org.appcelerator.calc
If everything is alright you will have a module in your Sample_Workspace folder with name calcand the given id.
you can work on it directly by importing it to your eclipse. and once done can build it using ant over the directory.
Hope it helps. Check the module creation guide.
Related
I am playing around with Instant Apps for Android.I installed all the correct packages and tired to create new Application with Instant App support (checked the box for Instant App when crating new application). The problem is that I always run into a problem with compile tools. Does anybody else have this problem and was able to find any workaround.
My environment:
Android Studio 3.0 Canary 1
Compile SDK: 25
Build Tools: "26.0.0 rc2"
Gradle plugin:3.0.0-alpha1
Gradle: tried both gradle-4.0-milestone1 and 2
Java 1.8/1.7
OS: tried both Windows 10 and Linux Ubuntu 16.4 LTS
The error:
Error: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.internal.aapt.AaptException: AAPT2 compile failed:
aapt2 compile -o /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/res/merged/androidTest/debug /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml
Issues:
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:520 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:521 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:568 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:594 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:595 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:597 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:598 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:599 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:600 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:601 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:602 invalid dimen
- ERROR: /home/simonp/Work/201705_InstantApp/InstantAppTest/feature/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml:603 invalid dimen
:feature:mergeDebugAndroidTestResources FAILED
The line in question contains (520):
<item format="float" name="abc_disabled_alpha_material_dark" type="dimen">0.30</item>
Hopefully I provided enough information to you to resolve the problem. Thank you.
Below are mentioned four different solutions: A, B, C, and D; pick one that suites you:
A) Fixing Android Studio via Ubuntu .desktop launcher file
This is an Ubuntu-only alternative to the general approach on Fixing Android Studio (see below). Note that you may still want to implement the part about Fixing the shell, and perhaps even revert any modifications to studio.sh to fully confirm this fix.
I got tired of patching my studio.sh for every canary update, so I came up with a better solution that eliminates this step. It works on Ubuntu and simply involves creating a .desktop launcher that sets the sick environment variable in question.
Make a note of where your Android Studio 3 is installed, e.g. ~/opt/android-studio-3.
Prepare your local icon and applications directory, in case the don't already exist:
mkdir -vp ~/.local/share/icons ~/.local/share/applications
Create an Android Studio 3 icon that will make your launcher stand out from the default icon and save it into ~/.local/share/icons/android-studio-3.png. Or you can use the one I made by rubbing a piece of cheese on the original (~/opt/android-studio-3/bin/studio.png):
Create an Android Studio 3 launcher file by copy and pasting this into a shell:
cat <<-EOF > ~/.local/share/applications/android-studio-3.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio 3
Icon=android-studio-3
Exec=env LC_NUMERIC="en_US.UTF-8" opt/android-studio-3/bin/studio.sh "%f"
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-studio
EOF
Make it executable:
chmod +x ~/.local/share/applications/android-studio-3.desktop
Now for the tricky part. Ideally you should be able find, start, and create shorts for Android Studio 3 from the Dash:
But personally, I almost always have trouble getting Ubuntu to detect my new or changed .desktop files. One solution is to log out and back in again. If anyone knows how to force a rescan please let me know!
B) Fixing Android Studio start script
Here's an easy, elegant, and semi-permanent fix: Only change the locale of Android Studio itself by modifying its startup script:
Edit studio.sh e.g. ~/opt/android-studio/bin/studio.sh or whatever your installation path may be.
Somewhere at the top of the file, below #!/bin/sh and before the first lines of code appear, add this:
LC_NUMERIC="en_US.UTF-8".
Here's the top part of my studio.sh for completeness:
#!/bin/sh
#
# ---------------------------------------------------------------------
# Android Studio startup script.
# ---------------------------------------------------------------------
#
LC_NUMERIC="en_US.UTF-8"
message()
{
TITLE="Cannot start Android Studio"
...
Restart Android Studio
A note on Upgrading Android Studio or Gradle
When you later upgrade your Android Studio installation, it will detect that you've modified studio.sh. You should let the installer replace the file, and afterwards perform the patch again as described above. Finally restart Android Studio, and you'll be ready again. The other solutions are not affected by this.
C) Fixing the shell; Gradle, Jenkins, all that
Building from the shell using gradlew also requires the fix to be applied. This only affects the shell and not Android Studio. Pick one:
Either specify the the fix on every invocation like this:
LC_NUMERIC="en_US.UTF-8" ./gradlew clean assDebug
Or to make this permanent for the project, edit the gradlew file in the root of the project and somewhere at the top add this:
LC_NUMERIC="en_US.UTF-8"
Like here:
#!/usr/bin/env bash
################################################################################
##
## Gradle start up script for UN*X
##
################################################################################
LC_NUMERIC="en_US.UTF-8"
# Add default JVM options here. You can al...
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
...
Or you can of course also add a global and permanent fix though the use of an alias, gr:
cat <<EOF>>~/.bash_aliases
# Fixing Android Studio 3 Canary bug https://stackoverflow.com/a/44304075/2412477
alias gr='LC_NUMERIC="en_US.UTF-8" ./gradlew'
EOF
Note this is how bash shell aliases are added on Ubuntu; if you're on a different OS perhaps you should append to ~/.bashrc or ~/.profile instead.
Then start a new shell and now instead of invoking ./gradlew use the new alias gr:
gr clean assDebug
The clear disadvantage of #2 is that this has to be applied to all projects manually. The advantage, I think, is that this will automatically be overwritten when a new gradlew is installed, much like studio.sh gets replaced, so you get to test if the bug has been fixed =)
D) Disabling APPT2 all together
Personally I wouldn't do this, but I've added it for completeness since it definitely is a way to make appt2 stop giving errors. Add this line to your gradle.properties: android.enableAapt2=false
The workaround is to switch your development machine to a locale which uses "." as a decimal mark.
It can be changed the following way:
I solved this problem by adding the following line to the gradle.properties files
android.enableAapt2=false
This issue has been fixed in the newest Android Studio stable. Upgrading your Android Studio to 3.0 should solve this issue for you (also no need to disable AAPT2).
Make sure you are not adding any units(dp) when using format="float"
I was facing the same problem because I auto-generated dimens using Android Studio using Extract dimen resource and it added unit type like:
<item name="margin_top" type="dimen" format="float">51.75dp</item>
It should be:
<item name="margin_top" type="dimen" format="float">51.75</item>
add
maven{
url 'https://maven.google.com'
}
to repositories work for me
Required libraries for 64-bit machines:
If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries with the following command:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
If you are running 64-bit Fedora, the command is:
sudo yum install zlib.i686 ncurses-libs.i686 bzip2-libs.i686
I've followed build instructions for Chromium for Snapdragon m54 stable build. I've added google play libs manually (as library_project is now missing in SDK). On
ninja -C out/Default swe_browser_apk
i'm getting error that "swe_browser_apk" target is not found.
gn ls out/Default
shows that there are lots of other targets including chrome_public_apk.
Why is swe_browser_apk missing? Any newer instructions since that times?
Update 1: i was unable to find "swe_browser_apk" in .gn files so is build doc outdated/incorrect?
It's much more easier to checkout m58 (instead of m54) branch and modify .gclient file to use git://codeaurora.org/quic/chrome4sdp/chromium/src.git#refs/remotes/origin/m58. Just like it's written in the build instructions you will get SWE_Browser.apk in out/Default/apks (swe_browser_apk target exists).
I cloned the Tensorflow Android example from https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android/, followed the steps at https://bazel.build/versions/master/docs/install-ubuntu.html to build it, but ran into problems with the following error:
tensorflow/core/kernels/split_v_op.cc:172:12: note: in instantiation of member function 'tensorflow::SplitVOpCPU::Compute' requested here
explicit SplitVOpCPU(OpKernelConstruction* c) : Base(c) {}
The build command that I used is:
sudo bazel build --genrule_strategy=standalone --spawn_strategy=standalone --local_resources 4096,4.0,1.0 -j 1 -c opt //tensorflow/examples/android:tensorflow_demo
please share ideas to fix this issue.
The issue is similar to the one posted at
https://github.com/tensorflow/tensorflow/issues/8641#issuecomment-288586320
The bazel builder does not work with latest NDK build that comes with Android Studio.
Need to use NDK r12b in the WORKSPACE file.
Code could be compiled, but still spilled out the warnings...
I'm trying to build my cocos project to android.
At first, I ran the following command:
cocos run -s {my_project_path} -p android
And I got errors of packages and symbols that weren't found, here is the first error:
error: package org.apache.http does not exist
import org.apache.http.Header;
and after the list of items that weren't found:
BUILD FAILED
......\AppData\Local\Android\sdk\tools\ant\build.xml:597: The following error occurred while executing this line:
......\AppData\Local\Android\sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
......\AppData\Local\Android\sdk\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.
I've read that it can be because my android project version was 23.
So I edited the version field in the android.properties file to 22
and ran the next command:
cocos run -s {my_project_path} -p android --ap android-22.
The first build output lines are saying it uses the android 22 api, but in the middle of the build, for some reason it starts to use version 23 and I receive the same errors above.
Did anybody have those errors?
Thank you,
Ben
If you want to use Android API 22, make sure you downloaded it via the SDK Manager.
One of the solutions to make it work with Android API 23 is by copying the file
[ANDROID SDK PATH]\sdk\platforms\android-23\optional\org.apache.http.legacy.jar
to
[PROJECT PATH]\cocos2d\cocos\platform\android\java\libs
before compiling your project. It worked for me.
Source: http://discuss.cocos2d-x.org/t/android-23-6-0-compile-errors-import-org-apache-http-header/26876/2?u=theslyest
Like the other comment said HttpClient isn't supported in android 6.0:
So, follow steps here. Worked for me and some others.
http://discuss.cocos2d-x.org/t/cant-compile-to-android/26874/3
That's because HttpClient isn't supported in android 6.0:
https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
You can read details here:
https://stackoverflow.com/a/32153434/1264375
Anyway easiest way to fix this is to change api level to 22 (as you said). But you have to do it in AndroidManifest (in my case I'm using api level 19):
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19"/>
Also you have to change api level in eclipse project settings in Android section.
i have installed android sdk and downloaded the latest version of phonegap 2.5.0 in fedora 18.
i am trying to create a project using the following command
./create ~/Desktop/android-project com.example.android android_project
am getting the following error.
which: no android in (/sbin:/bin:/usr/sbin:/usr/bin)
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
need your valuable suggestions.
finally found the answer
After checking my .bash_profile paths, and a bunch of digging, I finally found the cause of the issue. If you open up the create file (phonegap-2.5.0/lib/android/bin/create), there is a line that lists ANDROID_BIN=”${ANDROID_BIN:=$( which android )}”. The “which android” is the cause of the issue (or at least it seemed to be in my case). If you replace this line with the full path to your android tools (as listed below) it should resolve the issue. My final line looked like this:
ANDROID_BIN=/Users/ktyacke/DEV/adt-bundle-mac-x86_64-20130219/sdk/tools/android
The message you have means the phonegap script cannot find the android binary, which is included in the SDK you downloaded. Add the binary's directory, as well as the android tool's directory, to your path defined in ~/.bash_profile or any other location you're initializing the shell's environment variables.