GLBasic forum

Main forum => GLBasic - en => Topic started by: Bluepixel on 2019-Nov-09

Title: How do i use Android Studio?
Post by: Bluepixel on 2019-Nov-09
Hi there, I was super excited to try out android studio, when I compiled to android it told me to install android studio so I did. I created a simple hello world program and when I compiled for android it started up android studio, started updating some stuff and after a long time of waiting I just got errors.

Ive tried a lot to make this work but nothing seems to work.
Is there maybe a tutorial or guide on how to use android studio?
Title: Re: How do i use Android Studio?
Post by: MrPlow on 2019-Nov-09
Check the readme in the android studio folder created by GLB after you compile.
Also the Android Studio SDK Manager needs to have SDKs and libraries installed - you can find more about those online...


There are certain things you need to change and others you need to leave as is.

build .gradle at the app level >

  // GLBASIC_USER_NOTE versionCode, versionNumber, target SDK
        minSdkVersion 23
        targetSdkVersion 29


androidmanifest.xml - make sure you have it setup correctly if you edited it.

Below image is my SDK tools setup.



Title: Re: How do i use Android Studio?
Post by: Qedo on 2020-May-04
Hi. I can't compile Android with last version Android Studio 3.6.3. Getting below error:
Do you have any advice on how to proceed?
Below image is my SDK tools setup.
Version Java java 1.6.0-25
Thank you

"ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.1.0.
Disable offline mode and sync project
Show Details
Affected Modules: app"

Title: Re: How do i use Android Studio?
Post by: dreamerman on 2020-May-04
I will join Your question. What beside Android Studio is currently needed to compile for Android - like specific JDK/Java version or some other tools (as for other tools that I checked recently they for example advised to use older Python versions and so on) are needed? Or I missing some tutorial that's available here on forum and it's up-to date..
Title: Re: How do i use Android Studio?
Post by: spacefractal on 2020-May-04
Java 1.6.0-25 and any other sun java is not required at all as Android Studio uses OpenSDK version of Java instead, which is included with Android Studio and installed by default. So you dont need to use any of the official java version at all!

Also if Android Studio want you to update project settings to newer settings in a project, then the project can cause fails to compile completly.

But if that was happens, its very easy to revert it again:

in File/Project Structure/Project

Make sure Android Grandle Plugin uses version 3.4.1 and Grandle version uses 5.1.1. We can uses a bit newer version here, but those versions should works and still works nicely today (has just released PowerUp Elevation today)!

Also im do heard androidx.appcompat:appcompat:1.1.0 is depreacted? howover line is still there and should not cause any trouble throught when that grandle versions above is using.

After that, open the grandle file again and sync. Then any missing sdk, cmake and ndk that is required should now been downloaded automatic. This take some time.

Title: Re: How do i use Android Studio?
Post by: MrPlow on 2020-May-04
Also, make sure to sync project before builds - and might need a clean project with the new update.
Title: Re: How do i use Android Studio?
Post by: caffeinekid on 2020-Sep-07
I'm trying to build for Android and as far as I'm aware I've installed everything I need to.

Android Studio just comes up with configuring projects and doesn't get past that no matter how long I leave it. It also seems to be using my network connection constantly for some reason?

Any ideas guys?
Title: Re: How do i use Android Studio?
Post by: Qedo on 2020-Sep-09
I would like to help you if only Android Studio works for me
Title: Re: How do i use Android Studio?
Post by: caffeinekid on 2020-Sep-12
Well I got a apk compiled but it doesn't actually work it says it has a fatal error. Probably a schoolboy error as I've never used android studio before and with it was simple still like the old days.

Quotejava.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.tcksoft.blitz/org.libsdl.app.SDLGlbasic}: java.lang.ClassNotFoundException: Didn't find class "org.libsdl.app.SDLGlbasic" on path: DexPathList[[zip file "/data/app/com.tcksoft.blitz-8d5YTa9SdmINaA_Ah0AnzA==/base.apk"]
.... yaddayaddayadda.

No default activity? How has it/me managed that and any idea how to fix it please? Cheers.
Title: Re: How do i use Android Studio?
Post by: caffeinekid on 2020-Sep-13
I've got it building and running on my phone, but no sound? I'm using wav files but nothing is playing. The graphics are working but no sound.

Do I have to initialise the mixer or something? I don't have a clue.
Title: Re: How do i use Android Studio?
Post by: Qedo on 2020-Sep-13
try this:

https://www.glbasic.com/forum/index.php?topic=10861.msg96175#msg96175
Title: Re: How do i use Android Studio?
Post by: MrPlow on 2020-Sep-14
Hi,
For v16 sound should be working just fine.

I have been using this even when SETCURRENTDIR is used.

Code (glbasic) Select
FUNCTION LOADSOUNz: File$, ID,BUF
     
         LOADSOUND GETCURRENTDIR$()+File$, ID,BUF
ENDFUNCTION



Title: Re: How do i use Android Studio?
Post by: caffeinekid on 2020-Sep-15
Thanks I will give that a try and fingers crossed.

It's rather frustrating. To say the least.
Title: Re: How do i use Android Studio?
Post by: spacefractal on 2020-Sep-15
its a issue im fixed and gernot broke it again (etc did not used it). howover you can uses GETCURRENTDIR() what ever system throught.

Android is also not windows at all and there can been some frustation parts as well.
Title: Re: How do i use Android Studio?
Post by: spacefractal on 2020-Sep-16
also you should NOT update the  grandle version when you asked to that, that can break your project. so when its ask it, press no to this project.

Installing AS can been quite annoying until get anything running for the first project.
Title: Re: How do i use Android Studio?
Post by: caffeinekid on 2020-Sep-19
Sorry to be a pain yet again, but sound is working now (yay) and I got a debug build working on my phone with sound (yay) but as soon as I sign the APK it stops working (boo!) and all I get is a black screen for a second and then the app closes down again... :(

I'm pulling my hair out as I thought it was all working great and uploaded an update to google and didn't realise there was a problem until I started getting one star reviews saying the game no longer works at all..

Why does debug work but not a signed apk? It is signing and installing with no errors... but then blackscreen and force close. :(

Thanks guys. (help me obi-wan, you are my only hope...)

Quote2020-09-19 16:33:54.984 1239-1384/? E/InputDispatcher: channel 'eff7c1d com.tcksoft.blitz/org.libsdl.app.SDLGlbasic (server)' ~ Channel is unrecoverably broken and will be disposed!

Title: Re: How do i use Android Studio?
Post by: spacefractal on 2020-Sep-20
Do not optimize the app to save space (dont do the bundle, sign it as APK). Google might want you to do that, but they do still accept it. This can cause the app to fails to run.

Also do not update the grandle version to a newer version, when you get asked by that either. Howover if you did that, its easy to revert throught.

Also if you have installed a debug version on it, uninstall it first. you cant have a signed and a debug version on same device.

Also do you have a full log and do you use the steam beta (which is a bit newer version than the official)?

Also if you have a long loading time that is over 5 secs, this might cause to crash, if you dont update the screen either (SHOWSCREEN).
Title: Re: How do i use Android Studio?
Post by: MrPlow on 2020-Sep-20
Yes- dont use the protection, obsfucation or any of that...
Title: Re: How do i use Android Studio?
Post by: caffeinekid on 2020-Sep-21
I haven't optimised or used any fancy options. Just wanted to get it working - at all.

I didn't update gradle...

I put in some screen flashing code on the media loading so I can see if it did at least that and it was loading the media before crashing.

Funnily though I've just got the signed apk working on my phone but under strange circumstances. It doesn't work, but then if I clean the cache it will run.

Anyone have any idea what that's all about? Why does a new install have a cache with it and why does the game not run until it's cleared? :/

I think I'm really out of my depth and ought to give up on coding, especially for mobile. Things have changed a lot over the last half dozen years and it's just got more confusing to me.
Title: Re: How do i use Android Studio?
Post by: MrPlow on 2020-Sep-22
check your files in media folder if the filename is not correct case or has special chars or is missing - that can also crash the apk


[ EDIT - Also check your android manifest.xml to make sure the correct format is used ]

Also make sure minimum is set to android 6.0 (otherwise crash-time!!)

post your setup details here too from Android Studio AVD:

SDK version, Build-Tools version, etc. as that might flag something...
Title: Re: How do i use Android Studio?
Post by: spacefractal on 2020-Sep-22
that because glbasic does not have access to the files on the apk directly and needs to been extractly to the internal memory first. This is unlike Windows version, which have direct access to the file. This is nothing im can do. You can eventuelt try to do a DOESFILEEXIST() to see that does a different. This also force the file to been extracted before loading. But again, this should not been required anymore.

So Im have aboslute no idea without a example you need to give and also a logcat, so im have a change to see why its fails loading. Its property a memory issue somehow. But im need the logcat of a example, before im can help.

Also you should uses PLATFORMINFO$("APPDATA") on Android and not PLATFORMINFO$("DOCUMENT") which normally used on Windows. This is a little issue, but im choose not to fix it to avoid combatible issues. But in the later versions its should not matter througt.

Also you should NOT use any graphics commands at all when you resume your app, this will crash the game, etc in the GLB_ON_RESUME() and GLB_ON_PAUSE(). If you do that, its will crash on resume.

Also im have no idea how you uses your loading rutine without a example or a log. So you need to give a example so im can checkout. Im only need a Android Studio project to take a look on, not the glbasic source code.

You can do a DOESFILEEXISTS() command before a read to tryout, even its should do that automatic.

But im want the full logcat, so im can see what happens with the Java part.

Title: Re: How do i use Android Studio?
Post by: JohnnyB on 2020-Sep-27
where do i set the path to the sdk? glbasic looks unter c:, i have installed it on d:
Title: Re: How do i use Android Studio?
Post by: spacefractal on 2020-Sep-27
If you meant Android Studio, its best for its to been installed on the default path. Glbasic can been installed on other drive.

Android Studio uses Open JDK version of Java, so you do not need to install the official Java at all.