Eclipse w/ADT crashing with "import android." statement in editor - android

I'm new to Android Dev and am following developer.android.com/training. I'm at the "starting another activity" section and whenever I try to enter "import android.view.View;" into MainActivity.Java, Eclipse crashes on me. Specifically I can type in "import android" and once I add the period it crashes. Am I missing or need to install additional files? My OS is Linux Mint.
Thanks for your help
Beginning of the error log that was generated:
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fb090ea7c91, pid=2473, tid=140399027877632
#
# JRE version: 7.0_25-b30
# Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libsoup-2.4.so.1+0x6ac91] soup_session_feature_detach+0x11
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

I tried looking at the error log more closely and after searching this line:
C [libsoup-2.4.so.1+0x6ac91] soup_session_feature_detach+0x11
I came across this solution.
Adding the following to my eclipse.ini file fixed the problem, though I am clueless as to how or why...
-Dorg.eclipse.swt.browser.DefaultType=mozilla

I don't typically type in import statements. In Eclipse I use the Ctrl + Shift + O shortcut that will bring in all the missing imports.
Do you have your environment variables set, something like
setenv PATH /usr/local/jdk1.6.0_15/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.6.0_15

Related

`java.lang.NoClassDefFoundError: android/view/View` while trying to build 'HelloWorld' project from android-kawa in Termux

I've been trying to employ Kawa Scheme for developing Android project. I've found two repositories on GitHub: one called 'android-kawa', and another called 'KawaDroid'. They're both a bit dated (last updates were around 2012). In the case of 'android-kawa' I was able to reach the author, but he said he did't remeber enough to help me.
In the 'android-kawa' repo there's a bunch of scripts for setting up and working with the project. One of the scripts downloads the Kawa 1.13 tarball, applies some patches and then attempts to build it.
However, the build isn't supported in Termux, bevaise the config.guess script doesn't recognize the system. This issue can be easily resolved by downloading the latest versions of config.guess and config.sub.
Another problem is the format of the JVM bytecode. When I use the latest Java compiler, the generated bytecode contains (I believe) instructions for JVM8+, which aren't supported by the dx command. This isn't a problem if I run Java inside of Termux, because it installs the regular JVM, but if I want to include the Kawa jar in my APK (which is something that I want), then it becomes an obstacle.
This, again, can be resolved by forcing the Java version to 7 in javac. (But then, the compiler complsins that Java 1.7 is deprecated. I guess this is why the buildAPKs project uses ecj instead of javac)
Also, when I ./configure Kawa, I can pass it the path to the android.jar file (./configure --with-android=...). I have two android.jar files on my system:
~ $ locate android.jar
/data/data/com.termux/files/usr/share/aapt/android.jar
/data/data/com.termux/files/usr/share/java/android.jar
I don't know where they came from or how they differ between one another, but I've been prefering the second one.
So, when I have the kawa.jar available - and when I try to compile it with the command
~/android-kawa $ java -cp $(dirname $(locate android.jar |tail -n 1)) -jar kawa/kawa-1.13.jar -C KawaHello/src/kawa/android/hello.scm
I get the following error:
internal error while compiling KawaHello/src/kawa/android/hello.scm
java.lang.NoClassDefFoundError: android/view/View
at gnu.kawa.android.defs.<clinit>(defs.scm)
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1155)
at java.base/jdk.internal.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:42)
at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:185)
at java.base/java.lang.reflect.Field.acquireFieldAccessor(Field.java:1132)
at java.base/java.lang.reflect.Field.getFieldAccessor(Field.java:1113)
at java.base/java.lang.reflect.Field.get(Field.java:425)
at gnu.expr.ModuleInfo.setupModuleExp(ModuleInfo.java:195)
at kawa.standard.require.importDefinitions(require.java:308)
at kawa.standard.require.scanForDefinitions(require.java:219)
at kawa.lang.Syntax.scanForm(Syntax.java:65)
at kawa.lang.Translator.scanForm(Translator.java:1120)
at gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:64)
at gnu.expr.Compilation.process(Compilation.java:1908)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:305)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:290)
at kawa.repl.compileFiles(repl.java:823)
at kawa.repl.processArgs(repl.java:444)
at kawa.repl.main(repl.java:869)
Caused by: java.lang.ClassNotFoundException: android.view.View
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 24 more
I have obviously tried it without the -cp argument (with the same effect). The android/view/View.class entry is present in the list returned by jar -tf android.jar.
How can I further investigate in the root cause of the problem, and most importantly, how can I solve it?
It turned out that I have invoked Java incorrectly, and that it didn't see the android.jar file. It helped to invoke the compiler in the following way:
~/android-kawa $ java -cp $(locate android.jar |tail -n 1):kawa/kawa-1.13.jar kawa.repl -C KawaHello/src/kawa/android/hello.scm
(the difference is that I only have one -cp argument with jar files separated by :, and that I explicitly give the kawa.repl class name)

Xamarin MultiDex in VisualStudio 2015

Hi everybody I'm in a dead end!
Develop a PCL application using VisualStudio 2015, Xamarin and MvvmCross.
The Android app exceeds the 65K limit. I need to use Multidex!
For its implementation I have undertaken these guidelines:
Enabled checkbox for MultiDex
Extended MultiDexApplication class
General considerations:
Debug mode
MinSdk: 21
TargetSdk: 25
BuildTools: 23.0.3
Jdk 1.8.0_121
Xamarin.Android 7.3
Results:
"java.exe" exited with code 2. C:\Program Files (x86)\MSBuild\Xamarin \Android\Xamarin.Android.Common.targets 1965
<!-- Compile java code to dalvik -->
<CompileToDalvik
DxJarPath="$(DxJarPath)"
JavaToolPath="$(JavaToolPath)"
JavaMaximumHeapSize="$(JavaMaximumHeapSize)"
JavaOptions="$(JavaOptions)"
ClassesOutputDirectory="$(IntermediateOutputPath)android\bin\classes"
ToolPath="$(DxToolPath)"
ToolExe="$(DxToolExe)"
UseDx="$(UseDx)"
MultiDexEnabled="$(AndroidEnableMultiDex)"
MultiDexMainDexListFile="$(_AndroidMainDexListFile)"
JavaLibrariesToCompile="#(_JavaLibrariesToCompileForAppDx)"
OptionalObfuscatedJarFile="$(IntermediateOutputPath)proguard\__proguard_output__.jar"
/>
The error occurs during the compilation process.
I have consulted these sources:
"https://developer.android.com/studio/build/multidex.html"
"http://www.jon-douglas.com/2016/09/05/xamarin-android-multidex/"
"http://www.jon-douglas.com/2016/09/23/xamarin-android-multidex-keep/"
"https://przemekraciborski.eu/"
"https://forums.xamarin.com/discussion/64234/multi-dex-app-with-a-custom-application-class-that-runs-on-pre-lollipop"
"http://frogermcs.github.io/MultiDex-solution-for-64k-limit-in-Dalvik/"
I also have the ClassyShark.jar tool, but no dex or apk file is generated to explore it. Only the mono.android.jar file exists
Please I need help.
Thank you very much.
Responding to answer 1 and Luke Pothier's commentary are the results:
Setting output verbosity = Diagnostic
Case 1:
Using Android Sdk Location: C:\Program Files (x86)\Android\android-sdk installed with Visual Studio 2015.
4>_CompileToDalvikWithDx:
4> Creating directory "obj\Debug\proguard".
4> C:\Program Files\Java\jdk1.8.0_121\\bin\java.exe -Xmx1G -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\25.0.3\\lib\dx.jar" --no-strict --dex --output= ...
4> trouble writing output: Too many field references: 68102; max is 65536.
4> You may try using --multi-dex option.
4> References by package:
(list of references by packages)
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1965,3): error MSB6006: "java.exe" exited with code 2.
Case 2:
Using Android Sdk Location: c:\android\sdk with last proguard version 5.3.3 installed with Android Studio.
4>_CompileToDalvikWithDx:
4> Creating directory "obj\Debug\proguard".
4> C:\Program Files\Java\jdk1.8.0_121\\bin\java.exe -Xmx1G -jar C:\Android\sdk\build-tools\25.0.0\\lib\dx.jar --no-strict --dex --output=
4> trouble writing output: Too many field references: 68102; max is 65536.
4> You may try using --multi-dex option.
4> References by package:
(list of references by packages)
4>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1965,3): error MSB6006: "java.exe" exited with code 2.
This is likely to be caused by an issue between Xamarin and ProGuard, the fix to which is detailed here. Essentially, you need to replace the proguard.jar file that is in your Android SDK directory with the latest one from SourceForge (v5.3.3 currently).
EDIT: Per the error messages in your edits, the --multi-dex option isn't being passed during compilation. I would check your Android .csproj to make sure that the <AndroidEnableMultiDex> option is set to True for all build configurations. If that doesn't help, you may need to upload a reproducible sample somewhere.
EDIT 2: Per the comments, your Android SDK location needs to be somewhere where the path does not contain spaces. Program Files is no good. Personally I put mine in C:\Android\android-sdk.
After adjusting the path to the android sdk, removing the spaces and setting in the project file for the Droid platform the property AndroidEnableMultiDex in all configurations (appeared AndroidEnableMultipleDex) in true, I was able to compile without errors. Also, I have been able to check the contents of the generated dex files and both have references to Mvvmcross.
When I execute the application, it shows the splash view (ok!!!), but, an exception occurs when processing the view (activity) that has a binded viewmodel. Now, the viewmodel has null value. (Until the moment of having to activate the multidex, the application executed without any incidence)
My challenge now is to know if all the reference to Mvvmcross should be in the main dex, or is it due to another problem that I have overlooked?
Thanks in advance for his time to #LukePothier.
My self response:
After compiling and generate dex classes:
use dex2jar & jd-gui tools following Jon Douglas' hints in http://www.jon-douglas.com/2016/09/23/xamarin-android-multidex-keep/.
be very patient and persevere.
remove innesesary code and plugin if you can do it yourself.
I already have the application running !!!

Cannot compile bazel needed for tensorflow-android

I'm trying to explore the tensorflow android demo. I want to adapt the app using android studio.
However when I simply follow the instructions I get compilation errors no matter what I do:
Trying to compile tensorflow using bazel and NDK r12b:
$bazel build -c opt //tensorflow/examples/android:tensorflow_demo
ERROR: /home/myUser/libs/tensorflow_android/WORKSPACE:3:1: //external:io_bazel_rules_closure: no such attribute 'urls' in 'http_archive' rule.
ERROR: /home/myUser/libs/tensorflow_android/WORKSPACE:3:1: //external:io_bazel_rules_closure: missing value for mandatory attribute 'url' in 'http_archive' rule.
ERROR: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '#io_bazel_rules_closure//closure': error loading package 'external': Could not load //external package.
INFO: Elapsed time: 0.129s
Trying to compile a newer version of bazel following this advice:
$bazel version
Build label: 0.2.3-jdk7 // This is my current version of bazel
via apt-get:
$sudo apt-get upgrade bazel
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
E: Unable to locate package bazel
from source (tried bazel-0.4.2 and bazel-0.5.0):
$./compile.sh
INFO: You can skip this first step by providing a path to the bazel binary as second argument:
INFO: ./compile.sh compile /path/to/bazel
🍃 Building Bazel from scratch
ERROR: JDK version (1.7) is lower than 1.8, please set $JAVA_HOME.
or
$bazel build //src:bazel
ERROR: /home/myUser/libs/bazel/bazel-0.4.2/tools/build_rules/genproto.bzl:45:16: Traceback (most recent call last):
File "/home/myUser/libs/bazel/bazel-0.4.2/tools/build_rules/genproto.bzl", line 42
rule(gensrcjar_impl, attrs = {"src": at..."), <2 more arguments>), "_proto_compiler": attr.label(default = Label("//third_party/p..."), <4 more arguments>), "_jar": attr.label(default = Label("#bazel_tools//t..."), <4 more arguments>), "_jdk": attr.label(default = Label("#bazel_tools//t..."), ...)}, ..."})
File "/home/myUser/libs/bazel/bazel-0.4.2/tools/build_rules/genproto.bzl", line 45, in rule
attr.label(allow_files = proto_filetype, sing...)
allow_files should be a boolean or a filetype object.
ERROR: /home/myUser/libs/bazel/bazel-0.4.2/src/BUILD:130:1: error loading package 'src/main/protobuf': Extension file 'tools/build_rules/genproto.bzl' has errors and referenced by '//src:embedded_tools'.
ERROR: Loading failed; build aborted.
INFO: Elapsed time: 0.251s
switching aroung java-versions to see whether the bazel compiling issues come from there:
$sudo update-alternatives --config java
There are 4 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1074 auto mode
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
* 2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1072 manual mode
3 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1069 manual mode
4 /usr/lib/jvm/java-8-oracle/jre/bin/java 1074 manual mode
No luck so far :-/. Has anyone successfully compiled tensorflow for android from source?
What version of Tensorflow, NDK, bazel, java are required / compatible with each other? Do I really need bazel? (never worked with it anyway) Can't I just compile the android demo in android-studio like any other app?
I'm using Ubuntu 14.04, Cuda8.0, cudnn_v5.1, Titan X Pascal (not sure if these things matter)
Installing Bazel on Ubuntu can be done without compiling.
Follow all steps of the dedicated documentation: Install Bazel on Ubuntu

How to create Cocos2d-x v3.0 Beta 2 android ndk project

I got the build successful with cocos2d-x v2.2.2. Then I follow this tutorial to build cocos2d-x v3.0 beta 2 project
The command project-creator worked fine and I can create all supported platform projects.
Everything is ok except I have an error with build_native.py script:
line 25
print "Can't know cpuinfo, use default 1 cpu"
^
SyntaxError: invalid syntax
As I don't have any experiment with python, so I have no idea with this bug.
Here is my environment detail:
Latest python for windows 3.3.4
Windows 8, 64 bit
Latest android sdk r22.3, ndk r9c
Already set these environment variables: ANDROID_SDK_ROOT, NDK_ROOT, ANDROID_SDK_ROOT/platform_tools, ANDROID_SDK_ROOT/tools
For the variable NDK_MODULE_PATH, I can't find folder likeplatform\third_party\android\prebuilt in cocos2d-x v3.0, so I don't know what to do with it
Do I miss something?
Update: after searching on google, I found that on python 3, print should be use as method, like print(""), then I replace all tabs by spaces to avoid inconsistent use of tabs and spaces in indentation error. But I still got another exception:
The Selected NDK toolchain version was 4.8 !
make.exe: *** D:\SycnDir\game: No such file or directory. Stop.
Traceback (most recent call last):
File "D:\My Games\proj.android\build_native.py", line 166, in <module>
build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
File "D:\My Games\proj.android\build_native.py", line 153, in build
do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
File "D:\My Games\proj.android\build_native.py", line 89, in do_build
raise Exception("Build dynamic library for project [ " + app_android_root +
" ] fails!")
Exception: Build dynamic library for project [ D:\My Games\proj.android ] fails!
Finally I can make it worked. The exception is raised on these lines:
if os.system(command) != 0
raise Exception(“Build dynamic library for project [ " + app_android_root + " ] fails!”)
And I figure out space characters on my folder path caused ndk build failed. I can't believe this stupid bug make me waste two days. Now I just move my project into a folder without space and it worked like a charm.
The cocos2d-x 3.0 beta only works with Python 2.7 at this point. I suggest going back to Python 2.7 instead of trying to debug the script for Python 3.0.

dalvikvm is not showing LOGD messages of JIT Options

I have made some minor changes to /dalvik/vm/interp/Jit.cpp
(wrote some LOGD messages) and built dalvikvm using
$make dalvikvm
and the build was successful and got the executable in /out/
target/product/generic/system/bin/dalvikvm.
Now i started an emulator and pushed dalvikvm into /data and
executed a sample java program (with some 30 loops) using
$/data/dalvikvm -Xbootclasspath:/system/
framework/core.jar -classpath /data/CmdLine.jar TestAppActivity
(created CmdLine.jar from sample program by following
instructions given in http://davanum.wordpress.com/2007/12/04/command-line-java-on-dalvikvm/
)
now when i check the logcat there is no messages which i have
written using LOGD is displayed. Do we need to add any option to
dalvikvm command line to enable JIT? what could be the problem here?
Thanks
Jit is enabled by default if you are using android version above 2.2 i suppose. Your problem is the profiling of JIT has to be enabled in dvm. This can be don by looking into dalvikvm --help .... I think dalvikvm -Xjitprofile -Xjitverbose should do and before that export your environment variable to log the message too.
Try exporting the logs before running the dalvikvm something like this
export ANDROID_LOG_TAGS="ActivityManager:I MyApp:D *:S" the variables D -Debug S: lowest level V - verbose which is the level of log you need the application to be logged.
dalvikvm is just the starter binary. The important stuff lives in libdvm.so so you have to build and replace this rather than dalvikvm.

Categories

Resources