Red-Folder / bgs-core

Core code for the Cordova Background Service
Other
236 stars 105 forks source link

Build Android Error #93

Open sr2ds opened 6 years ago

sr2ds commented 6 years ago

Hello Friend, I'm trying to compile the basic implementation, following its documentation but I'm locking in the build. I think it's inexperienced with Java maybe you've already seen it.

After the android build, I get this:

compileDebugJavaWithJavac/home/david/Development/cordova/service/platforms/android/app/src/main/java/com/red_folder/phonegap/plugin/backgroundservice/BackgroundService.java:21: error: cannot find symbol
import com.red_folder.phonegap.plugin.backgroundservice.BackgroundServiceApi;
                                                       ^
  symbol:   class BackgroundServiceApi
  location: package com.red_folder.phonegap.plugin.backgroundservice
/home/david/Development/cordova/service/platforms/android/app/src/main/java/com/red_folder/phonegap/plugin/backgroundservice/BackgroundService.java:43: error: cannot find symbol
    private List<BackgroundServiceListener> mListeners = new ArrayList<BackgroundServiceListener>();
                 ^
  symbol:   class BackgroundServiceListener
  location: class BackgroundService

I think it might be a version problem but I just installed an environment from scratch reinstalling everything I could compile without the plugin.

Thank you very much for your time;

icecoolinux commented 6 years ago

I solve it. It's a file ubication problem, the aidl files was in a wrong path.

I fork the project and fix the problem, in this fork i add MyService class. https://github.com/icecoolinux/bgs-core.git

icecoolinux commented 5 years ago

Hello,

Try with:

cordova plugin add https://github.com/icecoolinux/bgs-core.git

El lun., 29 oct. 2018 a las 18:37, felipe-ff (notifications@github.com) escribió:

MyService.java is not present im my src/Android folder... do I have to install from another branch?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Red-Folder/bgs-core/issues/93#issuecomment-434090145, or mute the thread https://github.com/notifications/unsubscribe-auth/ARoqDiyjeEP3AyQKlEwma8ZzHgZuFsKEks5up3UogaJpZM4RLioN .

felipe-ff commented 5 years ago

Hello, Try with: cordova plugin add https://github.com/icecoolinux/bgs-core.git El lun., 29 oct. 2018 a las 18:37, felipe-ff (notifications@github.com) escribió: MyService.java is not present im my src/Android folder... do I have to install from another branch? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#93 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/ARoqDiyjeEP3AyQKlEwma8ZzHgZuFsKEks5up3UogaJpZM4RLioN .

I did that, the project in the plugins folder is now correct but the one in node_modules still seems wrong? I installed with: npm i cordova-plugin-bgs-core

felipe-ff commented 5 years ago

I created a new ionic project and it worked, so probably something wrong with my project...

Edit: Just had to ionic cordova platform rm android and add again to work!

wangxinyu4027789 commented 5 years ago

@felipe-ff can you offer a ionic project example with this plugin ? I met the same problem when I run cordova build command

icecoolinux commented 5 years ago

Yes, is a good idea.

El sáb., 3 de nov. de 2018 04:38, wangxinyu4027789 notifications@github.com escribió:

@felipe-ff https://github.com/felipe-ff can you offer a ionic project example with this plugin ? I met the same problem when I run cordova build command

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Red-Folder/bgs-core/issues/93#issuecomment-435567828, or mute the thread https://github.com/notifications/unsubscribe-auth/ARoqDuwfbj5UUu019pII3NXwfh-3lSqgks5urUgBgaJpZM4RLioN .

felipe-ff commented 5 years ago

Ok I'll try to remove my personal changes and publish to github this week.

felipe-ff commented 5 years ago

I published my plugin's folder to github, all you have to do is create a new ionic project "ionic start myProject" and add the plugin from: https://github.com/felipe-ff/ionic-bgs-core.git

Note that it will only work if your project's id is "io.ionic.starter", if you already have a working ionic project with a different id you will have to edit some parts of the plugin with your id.

icecoolinux commented 5 years ago

I already published a Readme change mentioning your project. Thank

El lun., 5 nov. 2018 a las 15:47, felipe-ff (notifications@github.com) escribió:

I published my plugin's folder to github, all you have to do is create a new ionic project "ionic start myProject" and add the plugin from: https://github.com/felipe-ff/ionic-bgs-core.git

Note that it will only work if your project's id is "io.ionic.starter", if you already have a working ionic project you will have to edit some parts of the plugin with your id.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Red-Folder/bgs-core/issues/93#issuecomment-435988995, or mute the thread https://github.com/notifications/unsubscribe-auth/ARoqDoAiofX5WQad450d54J9AWf_rTaHks5usIfUgaJpZM4RLioN .

wangxinyu4027789 commented 5 years ago

@felipe-ff ,@icecoolinux Thanks to all of you

icecoolinux commented 5 years ago

Hi,

I tried with cordova 8.1.2, gradle 4.4 and ionic 4.3.1.

This are the steps that I built successfully an android app: 1) ionic start myapp 2) cd myapp 3) ionic cordova plugin add https://github.com/icecoolinux/bgs-core.git

4) I found an error here, I edited the file plugins/com.red_folder.phonegap.plugin.backgroundservice/plugin.xml, the lines are: <source-file src="aidl/android/BackgroundServiceApi.aidl" target-dir="app/src/main/aidl/com/red_folder/phonegap/plugin/backgroundservice" /> <source-file src="aidl/android/BackgroundServiceListener.aidl" target-dir="app/src/main/aidl/com/red_folder/phonegap/plugin/backgroundservice" /> By: <source-file src="aidl/android/BackgroundServiceApi.aidl" target-dir="aidl/com/red_folder/phonegap/plugin/backgroundservice" /> <source-file src="aidl/android/BackgroundServiceListener.aidl" target-dir="aidl/com/red_folder/phonegap/plugin/backgroundservice" />

5) ionic cordova platform add android

6) Start the service from index.html, add:

7) ionic cordova build android

El mar., 13 nov. 2018 a las 14:45, felipe-ff (notifications@github.com) escribió:

For some reason this error started happening again to me...

BUILD FAILED

Total time: 2.219 secs

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. cmd: Command failed with exit code 1 Error output: C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundService.java:21: error: cannot find symbol import com.red_folder.phonegap.plugin.backgroundservice.BackgroundServiceApi; ^ symbol: class BackgroundServiceApi location: package com.red_folder.phonegap.plugin.backgroundservice C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundService.java:43: error: cannot find symbol private List mListeners = new ArrayList(); ^ symbol: class BackgroundServiceListener location: class BackgroundService C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundService.java:154: error: package BackgroundServiceApi does not exist private BackgroundServiceApi.Stub apiEndpoint = new BackgroundServiceApi.Stub() { ^ C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundServicePluginLogic.java:283: error: cannot find symbol private BackgroundServiceApi mApi; ^ symbol: class BackgroundServiceApi location: class BackgroundServicePluginLogic.ServiceDetails C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundServicePluginLogic.java:661: error: package BackgroundServiceListener does not exist private BackgroundServiceListener.Stub serviceListener = new BackgroundServiceListener.Stub() { ^ C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundService.java:43: error: cannot find symbol private List mListeners = new ArrayList(); ^ symbol: class BackgroundServiceListener location: class BackgroundService C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundService.java:154: error: package BackgroundServiceApi does not exist private BackgroundServiceApi.Stub apiEndpoint = new BackgroundServiceApi.Stub() { ^ C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundServicePluginLogic.java:636: error: package BackgroundServiceApi does not exist mApi = BackgroundServiceApi.Stub.asInterface(service); ^ C:\ProjetosInatel\MyIonicProj\platforms\android\src\com\red_folder\phonegap\plugin\backgroundservice\BackgroundServicePluginLogic.java:661: error: package BackgroundServiceListener does not exist private BackgroundServiceListener.Stub serviceListener = new BackgroundServiceListener.Stub() { ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 9 errors

This is driving me crazy what should I do to fix it? it seems like a deprecaed use of some API.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Red-Folder/bgs-core/issues/93#issuecomment-438368264, or mute the thread https://github.com/notifications/unsubscribe-auth/ARoqDgCrTFL8_IzRPYw7ohHIuyJgM3BMks5uuwVLgaJpZM4RLioN .

felipe-ff commented 5 years ago
4) I found an error here, I edited the file
plugins/com.red_folder.phonegap.plugin.backgroundservice/plugin.xml, the
lines are:
        <source-file src="aidl/android/BackgroundServiceApi.aidl"
target-dir="app/src/main/aidl/com/red_folder/phonegap/plugin/backgroundservice"
/>
        <source-file src="aidl/android/BackgroundServiceListener.aidl"
target-dir="app/src/main/aidl/com/red_folder/phonegap/plugin/backgroundservice"
/>
By:
        <source-file src="aidl/android/BackgroundServiceApi.aidl"
target-dir="aidl/com/red_folder/phonegap/plugin/backgroundservice" />
        <source-file src="aidl/android/BackgroundServiceListener.aidl"
target-dir="aidl/com/red_folder/phonegap/plugin/backgroundservice" />

This fixed it for me thanks.

Red-Folder commented 5 years ago

@icecoolinux @felipe-ff Is this a fix specifically for Ionic or is it needed for phonegap as well?