Android Studio Release vs Debug

Thanks, I will try it as soon as I get home (friday).

I cannot say, whether the fix works (i guess so, because I can see the new cppFlags.add lines in the .gradle file that weren't there before) because it brings in some new error I have not seen before. With the latest tip i get this:

 

Error:(216, 9) error: cannot find symbol method getActionBar()
Error:(1007, 91) error: cannot find symbol variable DIRECTORY_DOCUMENTS

Both of the errors point to the project .java file. The first is in this method:


 

    public void onCreate (Bundle savedInstanceState)
    {
        super.onCreate (savedInstanceState);

        isScreenSaverEnabled = true;
        getActionBar().hide();
        viewHolder = new ViewHolder (this);
        setContentView (viewHolder);

        setVolumeControlStream (AudioManager.STREAM_MUSIC);
    }

The second one is here:

public static final String getDocumentsFolder() { return getFileLocation (Environment.DIRECTORY_DOCUMENTS); }

 

It doesn't matter on which the drive the project is behaves the same.

That is funny, I have never seen that error.

Did you upgrade to Android Studio 2 as described here, and did you make sure you are using API level 23?

Had the same problem (using AS 1.51). I changed the level to 21 (not 23) and it went away. You can try that for a quick fix.

But Timur's suggestion is most probably the way to go...

No, I am using AS 1.51 as I found it impossible to upgrade to 2.0 (it just wouldn't upgrade). I will try the the tutorial link you posted and see if that helps. Also I will try to change the API level, thanks for the suggestion phil.

Yes, guys, please upgrade to AS 2.0 as described in the sticky post I linked above (switching to the "Canary Channel", ask for updates two times to make the update button appear, etc.), and then please check that if you create a new app in the Introjucer (API level 23 by default) that this compiles without errors.

We can then go from there if your actual projects still have errors...

Changing API to 21 did not help nor did upgrading to AS 2.0.

 

I still get the same error (plus some new warnings about the gradle plugin being old). Just to be sure, I tried to build the HelloWorld example. I just created the exporter for AS, opened it in AS and replaced the clang with gcc. The result is the same, it complains about DIRECTORY_DOCUMENTS variable.

 

Error:(1007, 91) error: cannot find symbol variable DIRECTORY_DOCUMENTS

which is:

public static final String getDocumentsFolder() { return getFileLocation (Environment.DIRECTORY_DOCUMENTS); }

So it is nearly the same as for my project, but there is one error less. HelloWorld does not complain about that
getActionBar() method. That line is in HelloWorld.java as well but the build process somehow doesn't mind.

Well I followed your procedure to upgrade to 2.0, and I can compile and run with no problem using debug variant. However I get an error ("Could not find method android()", see attached file) when choosing release variant. I use minimum skd version 22 as my Nexus10 does not support Android 6.

Any hint ? 

<EDIT> ah! Forget it, it was a signature problem. I fixed that but now I have another error. Let me ckeck it first before I bother you again, Timur...

<EDIT 2> The problem is still there with JUCE DEMO (see my post above)

OK. I restarted from scratch using latest JUCE tips and JUCE DEMO app. I am using android version 22 because of my target (Nexus 10).

Same problem: DEBUG version compiles and runs OK; RELEASE variant creates the following error:


:app:compileArmeabi-v7aReleaseSources
:app:lintVitalArmeabi-v7aRelease
:app:transformClassesAndResourcesWithExtractJarsForArmeabi-v7aRelease
:app:processArmeabi-v7aReleaseJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForArmeabi-v7aRelease
:app:transformClassesAndResourcesWithProguardForArmeabi-v7aRelease
Warning: Exception while processing task java.io.IOException: java.lang.ClassCastException: java.lang.String cannot be cast to java.io.File
:app:transformClassesAndResourcesWithProguardForArmeabi-v7aRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForArmeabi-v7aRelease'.
> java.io.IOException: java.lang.ClassCastException: java.lang.String cannot be cast to java.io.File
​

I'm lost... Any idea ?

Hey phil. I just checked and the Juce Demo compiles just fine here... both Debug and Release. Here's my setup:

- Android Studio 2.0 Preview 9
- OS X 10.11
- newest tip of JUCE
re-build Introjucer and then re-introjucer the Juce Demo project
- open in Android Studio, build and run...

If you do have a different setup, please tell me and we'll try to figure out why it's not working for you.

EDIT: the Release version builds but crashes on startup. Sorry for that. I'll try to fix it now.

Hey Timur

Thank you for your feedback. Rebuilding IntroJucer seemed to fix the release compilation problem. 

I do see the crash problem like you in Release variant. Debug variant compiles and runs fine.

 

The Android Studio crash in release variant is fixed now. Please update to the newest tip, recompile Introjucer and re-introjuce your project.

I confirm it now works in both release and debug variants.

Well done!

You know what Timur, despite all this "Windows is bad" thing, you managed to do this and it actually works! Both Debug and Release. Thanks, great work!

 

The release version is not that fast I'd hoped for, but it's faster than debug.

The release version is not that fast I'd hoped for, but it's faster than debug.

Yes, that is something we here at ROLI also observe. It's definitely not how I would expect it to be (the release build should run significantly faster than it does) and I am investigating it right now. It seems like the release build is not compiled with the right flags or something... and that particular problem has nothing to do with Windows.

I'll keep you updated.

Thanks, I'm interested in whatever you find out.

 

Jules said he get's about 60 FPS. That's definitely not what I get here. It's about 5 FPS maybe (depends on what exactly is being painted). And it might even not be faster than debug build. Maybe it's just my imagination (self suggestion...).

What Android device are you running this on?

Also, are you using the OpenGL renderer? The JUCE demo for example will always attach the OpenGL renderer on Android.

Yes, I think so... This is what I have:

 

        MainWindow (String name)  : DocumentWindow (name,
                                                    Colours::lightgrey,
                                                    DocumentWindow::allButtons)
        {
            setUsingNativeTitleBar (true);
            setContentOwned (new MainContentComponent(), true);

#if JUCE_ANDROID
            setFullScreen(true);
#else
            centreWithSize(getWidth(), getHeight());
#endif
            setVisible(true);  
#if JUCE_ANDROID
            setOpenGLRenderingEngine();
#endif
        }

     
#if JUCE_ANDROID
        void setOpenGLRenderingEngine() {
            openGLContext.attachTo(*getTopLevelComponent());
        }
#endif     

    private:

#if JUCE_ANDROID
        OpenGLContext openGLContext;
#endif

Looks OK to me!