Android setup: package android.content.Context doesn't exist.

994 views
Skip to first unread message

deva...@applozic.com

unread,
Apr 8, 2016, 5:12:35 AM4/8/16
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans
Desktop OS: MAC
Simulator
Device

How to setup Android platform.
Getting error package android.content.Context doesn't exist.

Chen Fishbein

unread,
Apr 8, 2016, 8:33:22 AM4/8/16
to CodenameOne Discussions, deva...@applozic.com
What are you trying to do? you need to use the CN1 API unless you are doing native interface and that should be done under the native/android dir

Devashish Mamgain

unread,
Apr 8, 2016, 8:37:45 AM4/8/16
to Chen Fishbein, CodenameOne Discussions
I was trying to integrated https://www.applozic.com to a sample app.


On Fri, Apr 8, 2016 6:03 PM, Chen Fishbein cf2...@gmail.com wrote:
What are you trying to do? you need to use the CN1 API unless you are doing native interface and that should be done under the native/android dir


Best,
Devashish Datt Mamgain
Cofounder & CEO Applozic Inc

Devashish Mamgain

unread,
Apr 8, 2016, 8:38:26 AM4/8/16
to Chen Fishbein, CodenameOne Discussions
Applozic is a native SDK for chat and messaging. I have gradle dependency and .aar file, couldn't figure out how to integrate it.

Chen Fishbein

unread,
Apr 8, 2016, 9:04:29 AM4/8/16
to CodenameOne Discussions, cf2...@gmail.com, deva...@applozic.com

Devashish Mamgain

unread,
Apr 8, 2016, 9:10:56 AM4/8/16
to Chen Fishbein, CodenameOne Discussions, cf2...@gmail.com
Thanks Chen.

Will try it out.

Gareth Murfin

unread,
Apr 8, 2016, 1:41:40 PM4/8/16
to CodenameOne Discussions, cf2...@gmail.com, deva...@applozic.com
use import com.codename1.impl.android.AndroidNativeUtil;

and  AndroidNativeUtil.getActivity()

to get a context.

Devashish Mamgain

unread,
Apr 10, 2016, 11:12:09 AM4/10/16
to Gareth Murfin, CodenameOne Discussions, cf2...@gmail.com
Hi Gareth,

Netbeans is showing error "package com.codename1.impl.android.AndroidNativeUtil" doesn't exist. Seems like I am missing something. Is there any sample project which ".aar" file imported for integrated 3rd party android sdk?

--
Best,
Devashish Datt Mamgain
Cofounder & CEO Applozic Inc
Let's chat! Book a time here

Shai Almog

unread,
Apr 10, 2016, 10:49:43 PM4/10/16
to CodenameOne Discussions, gareth...@gmail.com, cf2...@gmail.com, deva...@applozic.com
Hi,
the tutorial Chen linked (which is a part of the developer guide too: https://www.codenameone.com/manual/advanced-topics.html#_integrating_android_3rd_party_libraries_jni ) goes into details of an exact example of integrating a 3rd party native library into Codename One.

Notice that the IDE will report classes not found in the native code since the Android SDK compilation happens in the build servers. The same is true for iOS native code as the IDE doesn't include Objective-C support.

Devashish Mamgain

unread,
Apr 11, 2016, 5:01:58 AM4/11/16
to Shai Almog, CodenameOne Discussions, gareth...@gmail.com, cf2...@gmail.com
Thanks Shai.

I am bit confused on how to do I write code and test it before sending for the build.
Do I need to write some code, while Netbeans still shows the error, generate the build for android from Codenameone servers to validate if its working and then repeat the same process again?

Also, when I tried to generate the build, it says limit crossed and asking to upgrade the plan, can I first validate if things are working fine and then for a paid plan?

Gareth Murfin

unread,
Apr 11, 2016, 5:03:35 AM4/11/16
to Devashish Mamgain, Shai Almog, CodenameOne Discussions, Chen Fishbein
You could try writing most of the native code in android studio, when it builds and works move it over to netbeans and swap the contexts for AndroidNativeUtil.getActivity(), then send it off, and hope it works.. if not fix issue, send again.  
--
Gareth Murfin
(Android Freelancer - www.garethmurfin.co.uk)

sidiabale

unread,
Apr 11, 2016, 11:30:36 AM4/11/16
to CodenameOne Discussions, shai....@gmail.com, gareth...@gmail.com, cf2...@gmail.com, deva...@applozic.com
Hi Devashish,

It would be great (after you succeed with the integration) if you can make a cn1lib that wraps around your library. Your SDK looks interesting; I came across it (among others) while looking at viable options for real-time messaging, a feature that gets asked for quite a lot these days.

If you can make it easier for us to use your SDKs by providing a cn1lib (that's useful for all supported platforms), you'll benefit too via CN1 developers' clients. :)

All the best!

Devashish Mamgain

unread,
Apr 11, 2016, 11:36:23 AM4/11/16
to sidiabale, CodenameOne Discussions, shai....@gmail.com, gareth...@gmail.com, cf2...@gmail.com
Thanks Chidiebere

Yes, we will be making cn1lib soon, we have started getting many requests for Codenameone integration.
Reply all
Reply to author
Forward
0 new messages