I am trying to run this example. I reached upto "Modify the Client Application" and I am then having the following errors (and below is my file organization screenshot:
At this stage, as you can see below, I have the following issues in MainActivity.java.
activity_main.xml is called out but the project in its layout folder only has activity_register.xml (see here)
"Checkinendpoint" class is undefined but there is a CheckInEndPoint.java in the "MobileAssistant-AppEngine" project, as you can see in the image below. Is that not supposed to get picked up in MainActivity.java - how to import that? (doesnt work like a normal library import, i.e. "MobileAssistant-AppEngine" is not a library that "MobileAssistant" can reference.
Same question as above for CheckIn class that is also undefinted in the picture below.
Delete deviceinfoendpoint-v1-generated-source & messageendpoint-v1-generated-source from the Project-MobileAssistant and then right click on the MobileAssistant-appengine project then click on Generate Cloud EndPoint Library from Google Sub menu.
Related
Teaching myself Java, still very new. Last night I learned how to import this library into my project in Android Studio. But now I'm confused as to how to actually start using it.
I know that Java works with classes and that supposedly a library is just a collection of classes (and probably others things too...) that you can begin using once you import it. But the author of this library told me to just use this:
BackgroundMail bm = new BackgroundMail(context);
bm.setGmailUserName("sendername#gmail.com");
bm.setGmailPassword("sender_email_password");
bm.setMailTo("receiver#gmail.com");
bm.setFormSubject("Subject");
bm.setFormBody("Body");
bm.send();
But when I try to put that into another one of my classes, I get red errors all over the place. So then I tried to create a Java class within my app's files and I still got red errors. Could someone kindly help me, a total beginner, get started here? I'd like to use this library to send an email in the background of my app.
To import the library:
I followed this answer: https://stackoverflow.com/a/35369267/5241266 and used Approach 2.
MainActivity.Java: this is where I put the import code.
package moviehelper.moviesfree;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.creativityapps.gmailbackgroundlibrary.BackgroundMail;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
For now, I have not added the block of code that the author told me to use (see above).
The Gradle Console error:
I get the following error when doing Build -> Make Project:
error: package com.creativityapps.gmailbackgroundlibrary does not exist
import com.creativityapps.gmailbackgroundlibrary.BackgroundMail;
My project tree: I think there might be some problem with this structure. It looks like the library was added as its own project? Although I'm not sure.
If you don't want to use the JitPack approach as documented in the instructions, then look at the settings.gradle file in the Github example.
It includes both modules (app and the library).
Then, once that is setup, you can compile project(:libraryName) in the app/build.gradle file's dependencies section. Again, see the Github sample for the syntax.
With those two steps (plus one to download the library), it should be importable within the app code.
Assuming you followed along with the other steps on the readme, at the top of your code you need to tell the source file to import the classes:
import com.creativityapps.gmailbackgroundlibrary.BackgroundMail;
public class MainActivity extends AppCompatActivity {
[your code]
}
I would also recommend looking through the sample code included in the github project
You are doing some wrong steps friend. You can follow this
Find your gradle file with name buid.gradle (Project: [ YOUR_PROJECT_NAME ] )
Then find and add this line
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
You are done 50% now. Now press SHIFT+CTRL+ALT+S and wait for a window.
On the Window, select DEPENDENCY TAB on top.
Click on + BUTTON at top right. Click on Library Dependency.
Now paste com.github.yesidlazaro:GmailBackground:1.2.0 there.
Click on OK and exit the window. Gradle recompiles.
Now simply put your code, If RED syntax error showing, Click at the code where error is showing and when a BLUE pop comes, Press ALT+ENTER.
Everything done..!
I am developing an app in Android Studio. The package name is com.mycompany.myapp . Then, I want to reuse some codes from another package : com.theta360.sample.v2 .
To do this, I added a package named "com.theta360.sample.v2" in Android studio. And then, I simply copied the src directory of com.theta360.sample.v2 to project/app/src/main/, which also includes mycompany/myapp .
In MainActivity.java. I need to use class LogView from theta360.sample.v2. So, added "import com.theta360.sample.v2.view.LogView".
Then, I successfully build the app.
However, when I launched the app on device, I received error with message:
..Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.LogView" on path: DexPathList...
My questions are:
(1) why at run-time, the system try to look for android.view.LogView; LogView is from com.theta360.sample.v2.view . How to fix it?
(2) What's the correct way to use another package with source. Can I simply copy the codes as I did above?
I have solved my own question. The error is caused by LogView used in the layout xml. It should be changed to a name with it's package prefix.
I am on Android Studio 1.5.1
falnatsheh/MarkdownView
In the project's readme at github its gives instructions for use. These don't cover actually adding the project .. and I am learning Android programming (in fact I am making an app to keep my notes, as a sort of second step after "hello world").
how do I add it to the project so that I can follow the instructions on the project's readme? My default attempt was to follow these instructions:
File -> New -> Import Module .. add as ":markdownview" in my case, add it to the app's build.gradle, and then that should be it according to the site.
But that doesn't work:
The project's readme starts by saying you should add "compile 'us.feras.mdv:markdownview:1.1.0'" to the dependencies file (I am assuming they mean the Module:app one)... which looks like another way to add ":markdownview" to me.. but I did that too (and that instead of the ":markdownview"). Still the symbol does not resolve.
how do I add it to the project so that I can follow the instructions on the project's readme?
Add the following to your app/build.gradle file:
dependencies {
compile 'us.feras.mdv:markdownview:1.1.0'
}
which looks like another way to add ":markdownview" to me
Not exactly, but close.
but I did that too (and that instead of the ":markdownview"). Still the symbol does not resolve.
As with everything else in Java, you need to add an import statement.
I just created a scrap project in Android Studio, accepting all defaults in the new-project wizard. I pasted the above snippet in app/build.gradle and let Android Studio sync with the project files. I then added a reference to MarkdownView in the Java file, and Android Studio picked up the import without issue.
I am currently developing an Android app using cordova 2.0. Obviously the plugins.xml has been depreciated and everything is now housed in config.xml. I was just wondering if anyone has managed to get the Phonegap Screenshot plugin working in Eclipse and Cordova 2.0 working on android.
Plugin can be found:
https://github.com/josemando/phonegap-plugins/tree/master/Android/Screenshot
I have added:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
to my Android manifest xml. And made sure that:
<plugin name="Screenshot" value="org.apache.cordova.Screenshot"/>
is added to my config.xml (that now contains all plugin information from plugin.xml)
Screenshot.js is added to the directory:
assets/www/js/
However I am unsure where exactly to place the Screenshot.java file. The example has it in:
src / org / apache / cordova /
However as I did not have this directory I simply placed it in:
src/uk.co..appname1.appname2/
When I did this however it produced errors, the first one being:
The declared package "org.apache.cordova" does not match the expected package "uk.co.mysitename.appname1.appname2" Screenshot.java /Project Name/src/uk/co/mysitename/appname1/appname2line 8 Java Problem
This refers to this line in the Screenshot.js:
package org.apache.cordova;
The two suggested actions to fix this are to:
Move 'Screenshot.java' to package 'org.apache.cordova' (this directory doesn't exsist atm)
Or change package directory to 'uk.co.mysitename.appname1.appname2'
The second error says:
The method run() of type new Runnable(){} must override a superclass method
The suggested action for this being to "remove '#override' annotation"
I have tried to do every possible combination of these however I cannot seem to make progress and get it all to link up. Usually because it thinks that CordovaRef isn't referenced. I am unsure if the plugin even works on Cordova 2.0.0. I have some experience with Phonegap/Cordova but only in ios with Xcode and Objective C plugins. I am new to Java, Eclipse and Android. Any help or clarification on any of these matters would be greatly appreciated.
Answer resolved by:
Phonegap Screenshot plugin in Cordova 2.0.0
Answer/solution provided by Simon MacDonald
Has anybody gotten HTMLUnit (or HtmlUnitDriver) to work on Android apps?
This is the problem: I am getting the following error message:
11-26 16:27:26.617: E/AndroidRuntime(1265): java.lang.NoClassDefFoundError: org/w3c/dom/css/CSSRule
This is what I did: I tried adding adding references to the jars listed in the following link (under both Project Dependencies and Project Transitive Dependencies - compile only, excluding test jars):
http://htmlunit.sourceforge.net/dependencies.html
However Eclipse kept crashing, then I found a few questions saying some jars are already contained in the Android SDK:
xalan, xercesImpl and xml-apis
HtmlUnit on Android
HttpClient
Android Programming HtmlUnit
So I removed the references to these jars keeping only the following:
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-io-2.0.1.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
cssparser-0.9.5.jar
htmlunit-2.9.jar
htmlunit-core-js-2.9.jar
httpmime-4.1.2.jar
nekohtml-1.9.15.jar
sac-1.3.jar
httpcore-4.1.3.jar
It was at this point when the app was able to run but when the following line of code was executed I started to get the error:
final WebClient webClient = new WebClient();
11-26 16:27:26.617: E/AndroidRuntime(1265): java.lang.NoClassDefFoundError: org/w3c/dom/css/CSSRule
I did a web search and found that xml-apis-1.3.04.jar contains org/w3c/dom/css/CSSRule so I put that reference back to the project but the app wouldn't build at all saying the same error message described in the first link above:
[2011-11-26 16:39:52 - Myproj] Conversion to Dalvik format failed with error 1
Could somebody please shed some light on this?
xml-apis-1.3.04.jar contains core classes. You have to modify the jar and delete those classes.
Please note that, at least in current ADT version, you are getting a message explaining the problem:
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
Just as ULsies stated in the comments Htmlunit does this ==> HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.
which is exactly similar to webview widget provided inside the android sdk you dont need any other extra jar to open a web page inside your activity
as per google android documentation
A WebView is a View that displays web pages.It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.
add this to your activity layout xml file.
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
and this to your activity class file..
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.your url .com");
more on this here: http://developer.android.com/guide/webapps/webview.html