Cannot import cloudendpoint libraries of backend module in android studio - google-app-engine

I have created a backend module that contains the endpoints classes. It also has libraries that contain the endpointapi classes. During compile time, I am able to import both, the classes of that module and its library in the MainActivity file of the app. During run time however, it fails to detect the classes present in the library of the module. What could be the issue?
The error while running code is as follows:
Error:(10, 66) error: package com.example.shashank_pc.myapplication.backend.tempClassApi does not exist
The folder structure for backend module inside project is as follows:
For some reason, the classes inside the backend libraries, such as the those present in the tempClassApi and myApi folder, are not being detected
settings gradle file:
include ':app', ':backend'
App module gradle build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.shashank_pc.testcloudendpoints"
minSdkVersion 22
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'com/google/appengine/repackaged/org/apache/commons/codec/language/bm/*'
exclude 'com/google/appengine/repackaged/org/codehaus/jackson/impl/*'
exclude 'com/google/appengine/repackaged/org/apache/commons/codec/language/*'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.findbugs:jsr305:2.0.1'
testCompile 'junit:junit:4.12'
compile project(':backend')
}

Related

Shared components with ejected create-react-app projects

I have several projects that were created with create-react-app and have been ejected. Now, I have some components that are duplicated in each of the projects. Instead, I would like to have one shared component in a directory above the project directories.
The directory structure would be something like this:
- shared_components
- MySharedComponent.js
- project1
- project2
- project3
I updated the webpack.config.js files in my projects to allow importing files outside the src directory by adding my shared_components directory to the ModuleScopePlugin:
{
resolve: {
plugins: [
new ModuleScopePlugin([paths.appSrc, paths.mySharedComponents], [paths.appPackageJson]),
],
}
}
This successfully allows the files to be imported, but my shared_components directory doesn't seem to get compiled by the babel-loader.
I am getting the following error:
SyntaxError: /path/to/shared_components/MySharedComponent.js: Unexpected token <
This error occurs at the start of the JSX in my component, which is presumably caused by it never getting compiled to plain Javascript.
I tried updating the babel-loader config to include my shared directory, but it is not working:
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: [paths.appSrc, paths.mySharedComponents],
loader: require.resolve("babel-loader"),
// ...the rest of the config is just the defaults
}
How can I get my JSX component to successfully compile?

Google App Engine with Firebase - can't add dependencies

I'm trying to connect a backend module in Android Studio to Firebase using the tutorial here - https://cloud.google.com/solutions/mobile/firebase-app-engine-android-studio#adding_dependencies_to_the_backend_module
I cannot add the dependencies for some reason. I can't find them on the list. If I try to add them manually, I get a Gradle sync error.
For the main app module, Firebase is connected and it's functioning correctly. I set this up using Android Studio's build in Firebase tool. I've tried using this tool again but it's made no difference.
Here's my build.gradle for the backend:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.42'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.42'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.google.appengine:appengine-api-1.0-sdk'
compile 'com.google.firebase:firebase-server-sdk'
compile 'org.apache.httpcomponents:httpclient'
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
}
Here's the error I get if I add the dependencies manually, as shown in the code above:
Click here
You're probably getting errors on these dependencies. They don't have versions specified:
compile 'com.google.appengine:appengine-api-1.0-sdk'
compile 'com.google.firebase:firebase-server-sdk'
compile 'org.apache.httpcomponents:httpclient'
Every maven dependency requires a group id, artifact id, and a version string.
Also, the "firebase-server-sdk" dependency doesn't make sense to me. Access to firebase backend services is now done through the Admin SDK.
My guess is that the tutorial you linked to is simply very much out of date, and you can no longer follow it exactly, but maybe you can still learn something from it otherwise.

Gradle Could not resolve: com.microsoft.sqlserver:sqljdbc4:4.0

Please help me to resolve this error...
Added Dependency in build.gradle
**// https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4
testCompile group: 'com.microsoft.sqlserver', name: 'sqljdbc4', version: '4.0'**
After Refresh Gradle Project, getting the error below:
**Could not resolve: com.microsoft.sqlserver:sqljdbc4:4.0**
"It worked for me after adding in locally, here are my Steps in Eclipse Neon."
Step 1.
create 'lib' folder under main project
Step 2.
copy the jar file 'sqljdbc4' to lib folder
Step 3.
Add below dependency in 'build.gradle' file
repositories {
jcenter()
mavenCentral()
flatDir {
dirs 'lib'
}
}
dependencies {
compile name: "sqljdbc4-4.0"
}
Step 4.
Right click on main Project and refresh gradle
I am not sure about your build.gradle file.
It should work.
testCompile group: 'com.microsoft.sqlserver', name: 'sqljdbc4',
version: '4.0'`
is available in maven repository.
Did you gave
repositories {
mavenCentral();
}
as the repository in your build.gradle file? If you gave this , then it should work.
If it is not working please share your full build.gradle file here, and the error trace so that we can get more idea about your question
To resolve the dependency properly you need to add the maven url where the jar is located at.
Add this under repositories:
maven { url "http://repo.spring.io/plugins-release/" }
Should look something like this (this declares multiple repositories):
repositories {
mavenCentral()
maven { url "https://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/plugins-release/" }
}

Android Studio GAE Project Deploy: Class file is Java 8 but max supported is Java7

I have a Google App Engine project in Android Studio. In the past I have successfully deployed to my project to GAE many times. However, some project setting has changed and I can no longer deploy. I get the message:
java.lang.IllegalArgumentException: Class file is Java 8 but max supported is Java 7: javax/ws/rs/ApplicationPath.class in /Users/rob/AndroidStudioProjects/SpeedyMovingInventory/backend/build/exploded-app/WEB-INF/lib/javax.ws.rs-api-2.1-m02.jar
Unable to update app: Class file is Java 8 but max supported is Java 7: javax/ws/rs/ApplicationPath.class in /Users/rob/AndroidStudioProjects/SpeedyMovingInventory/backend/build/exploded-app/WEB-INF/lib/javax.ws.rs-api-2.1-m02.jar
Please see the logs [/var/folders/cn/3ktx4pj50hs7338v88b0sckh0000gn/T/appcfg3087406806803083082.log] for further information.
I have tried to set the source and target compatibility in my build.gradle, it is shown below:
// If you would like more information on the gradle-appengine-plugin please refer to the github page
// https://github.com/GoogleCloudPlatform/gradle-appengine-plugin
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.34'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.34'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.34'
compile 'joda-time:joda-time:2.8.2'
compile 'net.sargue:mailgun:1.0.0'
compile 'com.google.code.gson:gson:2.7'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
// Set this dependency if you want to use Hamcrest matching
testCompile 'org.hamcrest:hamcrest-library:1.1'
testCompile fileTree(include: ['*.jar'], dir: '/Users/rob/appengine-java-sdk-1.9.34/lib/impl')
testCompile fileTree(include: ['*.jar'], dir: '/Users/rob/appengine-java-sdk-1.9.34/lib/testing')
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
}
I have also used Android Studio to generate a sample GAE module and successfully deployed the sample to GAE. I compared the gradle files and settings and I don't see any differences. Please help, what am I doing wrong?
After lots of research, I have figured a fix. The library 'net.sargue:mailgun:1.0.0' apparently has a dependency of some sort on a java 8 lib (or something along those lines). I don't know why this hasn't caused me issues in the past, but it is now. Upgrading the lib to 'net.sargue:mailgun:1.3.2" resolves the issue.
I have had a conversation with the author of the mailgun library:
https://github.com/sargue/mailgun/issues/11
He had a dependency which were updated to Java 8, he fixed it in the new release.

Android Studio with AppEngine - Gradle dependencies

I'm trying the simplest example with Android Studio to create my own backend with this tutorial.
Backend is built and it seems like it's creating the client libraries as well.
The server starts and I can access it from localhost:8080
When I try to build my android app now, the app cannot find following classes
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.extensions.android.json.AndroidJsonFactory;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
neither the client model (called Registration, as in the sample).
How do I have to setup the dependencies of the project in gradle, so that the project can find the correctly generated client libraries?
Currently:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
applicationId 'de.unicate.cloudchat'
minSdkVersion 19
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:4.4.+'
compile 'com.android.support:support-v4:+'
}
Shouldn't that happen automatically in Android Studio?
I also encountered the same problem. I added the dependencies from this Stack Overflow Answer.
Add these dependencies:
compile ('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude module: 'httpclient'
}
compile ('com.google.http-client:google-http-client-gson:1.17.0-rc') {
exclude module: 'httpclient'
}
See this example
The newest version of the wizards adds the dependencies to your project automatically(as you mention), what version of android studio are you using?
The modified build.gradle file will have the extra dependency
compile project(path: ':<backend-module-name>', configuration: 'android-endpoints')

Resources