Titanium Appcelerator Android module : How to create a proxy? - android

This is not a question but is an answer to the issues I was stuck up while creating custom Android module for Titanium appcelerator.
I was able to run the ExampleProxy provided by the framework but was having problems creating my own Proxy class.
I was able to access the proxy. After lot of search I got the reference of following question -
http://developer.appcelerator.com/question/153993/how-to-create-a-proxy#answer-264746
Following response partially works-
"Thank you very much Benjamin Bahrenburg for the clarification. Also i
thank Mads for your quick response.
Exact answer i was looking for : Need to remove the files in the bin,
libs, and build folder. Then do a clean, in Eclipse. After all of that
it tends to build. Please make sure you are using Ti 3.1.0 ( not 3.1.1
which has an issue)."
In addition on windows 7 machine I had following observations-
The Module-generated folder in C:\Users\username\AppData\Local\Temp\ must be deleted.
In the module folder delete following contents - entire contents of bin and libs and delete everything in build except \build\generated\Application.mk

It cost my 1 day to solve this problem.
to successfully create and run a ViewProxy, you have to:
change its file/class name (from ExampleProxy) to ViewProxy
clean the dirty files, including: build/, dist/, and some "lib.so " files in libs/ folder.
execute ti clean in your "Titanium app" folder.
your ViewProxy is not the same as the module name. e.g. your module name is: "GaodeMapModule", your proxy name should not be: "GaodeMapProxy", it doesn't work.

Related

Use custom name for android module in flutter project

I have an existing Android project.
Also, I created a new flutter project. I copied my project to it. Now I have such tree in the file system:
my_flutter_project/
android/
my_android_module_name/
src/...
lib/...
ios/...
When I try to run flutter project I have such error:
No application found for TargetPlatform.android_arm64.
Is your project missing an android/app/src/main/AndroidManifest.xml?
So I should somewhere write my_android_module_name instead app but where?
I'm fairly sure that a lot of the flutter stuff is hard-coded to use the :app project and app directory, not just the manifest (See the gradle reader). You could open a bug in the flutter repository about it, but I don't imagine it's something that will be changed very quickly as it would be a fairly large change.
If you really want to use a different project structure, you could look into using a FlutterView - see this example. I can't guarantee that it still doesn't have the same requirement of using the app folder though.
I'd recommend renaming the module to app or creating a fresh project and just copying in the relevant files - it would probably save you time and frustration in the long run if you're committed to using flutter.. They update the android & ios files occasionally, and if you have the same structure it's a lot easier to merge in the changes.

Painful Unity project export to Android each build (I'm doing something wrong)

I would like to know if there is a faster way than the following steps to test Unity app with Android (gradle export):
Change something in unity
Build settings & Run --> Export (new Gradle)
Now the old gradle in the Android project is replaced, so i need to copy paste from a backup
The Res folder is also replaced, so I need to copy paste the backup one
Finally Build and Run the APK on the device
Steps 3 and 4 are obviously what makes this process painful (slow), I found the manifest.xml of the Unity android plugin, so this one stays the same (edited it directly in Unity). So am I doing something wrong ? Is there a way to update only parts of the Android project (like, if I only changed one line of a C# Script, just rebuild this one for Android)
Tell me if I'm not clear enough with my explanation :)
EDIT: I Already posted this in Unity forum but I didn't get any answer yet after a day
You can create your own Gradle file.
Put it in Plugins/Android folder and call it mainTemplate.gradle
It will use that.
As far as I know, there is no way to rebuild just part of it.
Unity does not create java files from the c# code. It creates its own modules and uses them directly.
BTW, why are you exporting at all? Why not compile directly to your device?
I just wanted an additional answer for this question even though it is a bit old (just in case anyone else in the future is wondering about this like me). I personally need to make use of both Android Studio and Unity so making a plugin wasn't really an option for me.
Now I have a custom gradle file as explained in the accepted answer. However I have also added an additional resource folder (Explained well by Android here: https://developer.android.com/studio/write/add-resources.html).
You basically just have to edit your custom gradle file to add paths to both resource directories. Add the resources you don't want Unity to overwrite to the other resource folder.
Now every time you rebuild to the project the resources remain and you don't have to copy them back in.
You can export a formal Android project first, using this project to build your final apk.
Then You could write an EditorUtil script in you Unity project, The script does following things:
1.export an temporary Android project to another folder.
2.copy assets folder and jnilib folder or any other folders you want to replace in your formal Android project.
Everytime you want export your project, just trigger the export function in you Unity Editor, It will copy and paste folders automaticlly, then your formal project will be ready for building.

Android Studio ClassNotFoundException: com.mysql.jdbc.Driver after adding module

The error I am getting is java.lang.ClassNotFoundException: com.mysql.jdbc.Driver even though I have already added the .jar file by going to file -> project structure -> import .JAR Package. What could be the issue here? Image of module inside project structure:
Try putting jar file in your lib directory, then re-starting tomcat...
problem is Class.forName("com.mysql.jdbc.Driver"); it tries to load the driver, but it is not getting it, this is the reason you are getting java.lang.ClassNotFoundException.
check that your jarfile should be in class path
I had a TON of trouble with this for some reason. It is mentioned elsewhere that only 3.017 driver works, and since I made such detailed instructions I figured I'd share them. (My initial purpose was to give steps to reproduce error that I could use to ask a question here and elsewhere. No, I can't begin to guess why I had so much trouble now looking back)
To: Get JDBC Driver in Android app
New Android Project - AndroidJDBCTest, Target Android4.03, minimum
sdk 8 (Android 2.2), package name “com.test.AndroidJDBCTest”
Right click on project, new folder “libs”
Download Mysql JDBC Driver from here and extract it to your
filesystem.
Browse to the root directory after extracting and drag and drop the
jar mysql-connector-java-3.0.17-ga-bin.jar into /libs in your project
in project explorer inside Eclipse., using the default “copy” setting
for the drag and drop.
Right click on the Eclipse Project, Build Path-Configure Build Path,
Add JAR under libraries tab - Browse to /AndroidJDBCTest/libs and the
jar file and click ok
NOTE: It shows up now under “Referenced Libraries” node (if Eclipse is
set to show it)
Add code from here to the end of onCreate() - basically
Class.forName("com.mysql.jdbc.Driver").newInstance();
Attach Honeycomb device such as Motorola Xoom family Edition and run
Why are you trying to access MySQL DB from Android native? First it might work but it is not recomended. You can do it easily with PHP and JSON responses.
Check those:
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql
http://www.tutorialspoint.com/android/android_php_mysql.htm
http://sampleprogramz.com/android/mysqldb.php
You can also download my project with HttpURLConnection since org.apache library has been deprecated.

archive for required library could not be read or is not a valid ZIP file

Before coming to the problem let me explain what I did that has landed me in the problem.
I created an account on github and made a repository named Android.
Then I installed github client in my windows 7.
Then I opened this client, provided my authentication and cloned the repository to a local directory C:\Users\Aniket\Documents\GitHub\Android(This folder has the .git folder in it).
Then I went to my Eclipse ADT and installed EGit plugin as described here. Also I
Then in Eclipse I right click on my project TicTacToe go to Team->Share Project and provide my repository path i.e C:\Users\Aniket\Documents\GitHub\Android.
My Project was added to the local repository and in my github client it shows me all option to commit file in the actual repository on the github site.
But my project is suddenly showing error with a red '!' sign on it.
Description --> Archive for required library: 'C:/Users/Aniket/AndroidWorkspace/TicTacToe
/libs/android-support-v4.jar' in project 'TicTacToe' cannot be read or is not a valid ZIP file
Resource --> TicTacToe
Path Location --> Build path
Type --> Build Path Problem
Note : the Error was a single line displayed in error console on Eclipse. I just split it up for readability.
Even after detaching repository it shows that error.
Has anyone encountered this scenario before. What is the solution or workaround? I googled and first few links suggest it is an Eclipse bug. Please suggest what can be done to bring my project back to executable state?
It is an Eclipse bug. I have faced the similar problem several times. closing and reopening the project works sometime. if it doesn't work try restarting Eclipse.
I've seen the same issue. I removed that jar file, and then rightclick on the project, select maven, and do "update project...". The jar was downloaded again, and the problem was gone.
There is other case to display error Archive for required library
Right click on project and open --> project project properties --> java build path --> Android private libs
if there are two jar files with same name then remove one from libs.
jar file may the hidden some times then
open you libs folder in window and check if any hidden files are exist
Organize --> folders and search options --> view --> check show hidden files
and Delete the hidden jar file , The same cass delete if hidden java fies exist in src and packages if any
Looks like everyone has different story to tell! For me, I had to delete the error from eclipse Markers tab, and then cleaned the project again. Before that, I closed and re-opened the project/eclipse several times as suggested by #rachit, which did not work for me.
In my case, i'd downloaded project from internet, after unzipping project some files had been blocked, just unblock files and try again, then problem was solved.
In my case I tried all the tips suggested but the error remained. I solved changing version with a more recent one and writing that in the pom.xml. After this everything is now ok.
In my case restarting Eclipse did not solve the problem. I restarted the computer and did a Project -> Clean in eclipse
A solution that worked for me:
go to *.classpath and delete the line :
<classpathentry kind="lib" path="the_problematic_class.java"/>
Could be due to corrupted jar files as well. Better to check that first as that was the reason in my case:
jar tf myjar.jar
should list the content inside.
i was facing same problem in Eclipse Mars. I downloaded the jars from [https://oss.jfrog.org/webapp/#/artifacts/browse/tree/General/repo/org/ethereum/ethereumj-core/1.0.0-SNAPSHOT][1]
and replaced it in the directory.
I got error while adding ethereum.jar using pom.xml at C:\Users{machineName}.m2\repository\org\ethereum\ethereumj-core\1.0.0-SNAPSHOT\ethereum-core-1.0.0-SNAPSHOT.jar , i added the downloaded jar(ethereum-core-1.0.0-SNAPSHOT.jar) here and the problem was solved.
I will say that it can be that some answers work for some cases, but for me it was necessary to go an extra mile. So I will try to make a summary of what can be done:
Verify that the jars are intact:
jar tf myjar.jar
Restart eclipse and update projects setting over right click on project -> Maven -> Update project
The option which has work for me was to navigate in the workspace folder and then delete the files:
.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache
.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache
After that restart eclipse and rebuild project.
I found no duplicates anywhere and tried restarting eclipse, rebuild project. I was getting error for only one libary. So I just tried to rename the jar file from ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar to ksoap2-2.5.8.jar
So if none of the problems solves from above you can also try this one
In my case, the java installation was not proper. So, I uninstalled Java and reinstalled a new version. Now, it works.
For us, the problem seemed to be the size of the .jar file. I would recommend doing the following test to see whether this is the case or at least rule it out. First have a look at other jars in your Eclipse project and compare them to the problemetic jar. Is it a lot bigger than the others? If so, try the following workaround. Else, this answer probably won't help you. Before starting, configure Windows to treat .jar files as .zip files with the following command line command:
assoc .jar=CompressedFolder (see https://superuser.com/questions/121540/can-you-configure-windows-to-open-jar-files-like-zip-files-without-a-3rd-party-t)
Optional: A simple Test
Before trying the workaround, here is a test to see if it is indeed the jar file size that's tripping you up.
Create a large .jar full of random .class files that aren't in your problematic jar. You can do this by making a folder full of files, zipping it, and renaming the .zip extension to a .jar. Windows might warn you about changing the extension. Ignore this. Make sure you have enough files in the folder so that it's a bit larger than the problematic jar.
Try to import this artificially created jar. If it fails with the same error, then size is probably the issue.
The Workaround
If it is indeed size that's the problem, which you might have identified by doing the optional simple test above, you can try the following workaround.
Decompress your .jar file. You should be able to do this easily in Windows
Split the folder you get from step 1 into smaller sub-folders. It could be just two folders, or more, depending on how big the original is. You want the folders to be smaller than some of your existing "good" jars so that size won't be an issue. Make sure to keep the package structure intact when you're doing this.
Zip up all the folders you created in step 2, and rename the .zip to .jar.
Import all of the .jars from step 3 individually.
The steps might be a bit unclear, so here's an example. Imagine your jar file was called mylib.jar. You unzip this to a folder called mylib. Inside, let's say there are three sub-folders called package1, package2 and package3. Create 3 folders called mylib1, mylib2 and mylib3, and put in package1, package2 and package3 respectively. Then zip these up and rename extension to .jar. You'll then be importing mylib1.jar, mylib2.jar and mylib3.jar.
For Java web application, web.xml added as jar in the project. In project explorer, try to find web.xml as in jar icon and remove from the project. Error will go away!!
I was stacked on this problem for days despite searching for a solution on the net. I first moved my project to Netbeans and all worked fine. I then returned to eclipse->properties->java compile-> Building and changed "Incompartible build path" option from error to warning and then did maven update and it worked.
I realize this is an old question, but I have yet another solution if none of these work for other people coming across this thread.
I had this same problem, and spent alot of time trying to figure it out, only to find that my Eclipse classpath/buildpath has a .json file in it, it doesn't like that, so it wouldn't compile.
So, check to make sure no text files or json files, etc are in your build path.
I had accidentally put the web.xml into the build path :x

Built Android App with Jenkins including Library Projects

I have just set-up my local jenkins installation on my mac...
Now i have tried to create an ant built which builds my app as soon as i check-in a new change. The ant script is working great as long as i only use it in the project...
cd into the folder
ant release
It is able to find all library projects i'Ve included (ActionBarSherlock, ViewPagerIndicator, NineOldAndroids, HoloEveryWhere, PocketChange)
As soon as i put this on my jenkins installation everything breaks.
My main folder-organisation is like this:
Projects/Project
Projects/ProjectLibrarys/Library
Eclipse referes to those libraries like this: android.library.reference.2=../Project Librarys/ActionBarSherlock/library
I can't use absolute links (because i think they will fix the issue) but eclipse or ant doesn't like them.
I have really no idea how to fix it?
Will i have to edit the build.xml (i've added it into the folder ext/commonbuild/commonbuild.xml so i have the same android build file for all my projects)
If you need more code let me know.
Thanks in advance...
Ok i was able to solve my issue by adding a customproject.properties file with a seperate link for the build.
There is still one issue. It seems that ant doesn't use the customproject.properties for my library project i've added. This library project includes another library project and as soon as i build it has a wrong relative url.
Does someone know how to use the customproject.properties even for the project libraries?
As bluszcz mentioned, I checked out two modules and i was able to build my apk via Jenkins without having two project.properties or customproject.properties file.
On Jenkins Configure Screen, Under Source Code Management - Subversion Modules,
Give the url for your android project (say, SampleAndroidProject)
https://goxxx.com/svn/repository/projects/trunk/SampleAndroidProject
Provide local module directory as 'SampleAndroidProject'
Provide the svn url for your library project (say, google-play-services_lib)
https://goxxx.com/svn/repository/projects/trunk/google-play-services_lib
Provide local module directory as 'google-play-services_lib'
Save and build again.

Categories

Resources