The package com.google.appengine.api.urlfetch cannot be found - google-app-engine

We are trying to use a URL fetcher to retrieve get the response of an GAE API method, using the following code. As far as I'm aware this code is correct, but there seems to be a problem with the imports. Am I missing a dependency from the gradle build file perhaps? Have looked around on the internet but haven't got anywhere.
import com.google.appengine.api.urlfetch.HTTPHeader;
import com.google.appengine.api.urlfetch.HTTPResponse;
import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
import java.io.IOException;
import java.net.URL;
import java.util.List;
…
URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService();
try {
URL url = new URL("<URL we use is redacted>");
HTTPResponse response = fetcher.fetch(url);
byte[] content = response.getContent();
// if redirects are followed, this returns the final URL we are redirected to
URL finalUrl = response.getFinalUrl();
// 200, 404, 500, etc
int responseCode = response.getResponseCode();
List < HTTPHeader > headers = response.getHeaders();
for (HTTPHeader header: headers) {
String headerName = header.getName();
String headerValue = header.getValue();
System.out.println(headerName + " " + headerValue);
}
} catch (IOException e) {
// new URL throws MalformedUrlException, which is impossible for us here
}
We are getting the following error:
/Users/Michael/Documents/GradeMe/app/src/main/java/com/ip/grademe/Register.java
Error:(12, 41) error: package com.google.appengine.api.urlfetch does not exist
Error:(13, 41) error: package com.google.appengine.api.urlfetch does not exist
Error:(14, 41) error: package com.google.appengine.api.urlfetch does not exist
Error:(15, 41) error: package com.google.appengine.api.urlfetch does not exist
Error:(73, 17) error: cannot find symbol class URLFetchService
Error:(73, 43) error: cannot find symbol variable URLFetchServiceFactory
Error:(77, 21) error: cannot find symbol class HTTPResponse
Error:(85, 26) error: cannot find symbol class HTTPHeader
Error:(87, 25) error: cannot find symbol class HTTPHeader
EDIT: The gradle.build file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.ip.grademe"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile project(path: ':backend', configuration: 'android-endpoints')
}

Related

React Native Navigation does not exist

I had to take a break from working on my react native app for a couple of months and when i came back to work on it again i couldn't boot anything up and i am getting a load of React Native Navigation errors...
I dont really know where to start with this, i have made some changes to the java files but nothing seems to get me out of this hole...
the error is below... if anyone knows how to deal with this i would be really greatful
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainActivity.java:3: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationActivity;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainActivity.java:5: error: cannot find symbol
public class MainActivity extends NavigationActivity {
^
symbol: class NavigationActivity
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:21: error: package com.reactnativenavigation does not exist
import com.reactnativenavigation.NavigationApplication;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:22: error: package com.reactnativenavigation.react does not exist
import com.reactnativenavigation.react.NavigationReactNativeHost;
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:27: error: cannot find symbol
public class MainApplication extends NavigationApplication {
^
symbol: class NavigationApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:29: error: cannot find symbol
new NavigationReactNativeHost(this) {
^
symbol: class NavigationReactNativeHost
location: class MainApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:47: error: method does not override or implement a method from a supertype
#Override
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:51: error: method does not override or implement a method from a supertype
#Override
^
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:53: error: cannot find symbol
super.onCreate();
^
symbol: variable super
location: class MainApplication
C:\git\BattleBuddy\android\app\src\main\java\com\battlebuddy\MainApplication.java:54: error: cannot find symbol
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
^
symbol: method initializeFlipper(MainApplication,ReactInstanceManager)
location: class MainApplication
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
This is from the build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
RNNKotlinVersion = "1.3.61" // Or any version above 1.3.x
RNNKotlinStdlib = "kotlin-stdlib-jdk8"
}
repositories {
google()
mavenLocal()
mavenCentral()
jcenter()
maven { url "$rootDir/../node_modules/react-native/android" }
maven { url 'https://maven.google.com' }
// ADD THIS
maven { url "https://www.jitpack.io" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61"
classpath 'com.android.tools.build:gradle:3.6.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
this if from the app build.gradle
dependencies {
implementation project(':#react-native-community_async-storage')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-vector-icons')
implementation "androidx.appcompat:appcompat:1.0.0"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:design:27.1.0'
}
This is the mainapp
public class MainApplication extends NavigationApplication {
private final ReactNativeHost mReactNativeHost =
new NavigationReactNativeHost(this) {
#Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
main activigty just looks like this
package com.battlebuddy;
import com.reactnativenavigation.NavigationActivity;
public class MainActivity extends NavigationActivity {
}
If there is anything you can think of that would help a lot

Jhipster webpack compilation error when checking an array value

I am using Jhipster with Angular. I have a method that is trying to check to see if the user in as admin.
import { Component, OnInit } from '#angular/core';
import { ActivatedRoute } from '#angular/router';
import { IPost } from 'app/shared/model/post.model';
import { AccountService } from 'app/core/auth/account.service';
import { Subscription } from 'rxjs';
import { Account } from 'app/core/user/account.model';
#Component({
selector: 'jhi-post-detail',
templateUrl: './post-detail.component.html'
})
export class PostDetailComponent implements OnInit {
post: IPost | null = null;
authSubscription!: Subscription;
account: Account | null = null;
constructor(protected activatedRoute: ActivatedRoute, private accountService: AccountService) { }
ngOnInit(): void {
this.activatedRoute.data.subscribe(({ post }) => (this.post = post));
this.authSubscription = this.accountService.getAuthenticationState().subscribe(account => (this.account = account));
}
previousState(): void {
window.history.back();
}
private isAdmin(): boolean | undefined {
return this.account?.authorities.includes('ROLE_ADMIN');
}
}
When the code is compiled I get an error
ERROR in ./src/main/webapp/app/entities/post/post-detail.component.ts 21:30
Module parse failed: Unexpected token (21:30)
File was processed with these loaders:
* ./node_modules/angular2-template-loader/index.js
* ./node_modules/cache-loader/dist/cjs.js
* ./node_modules/thread-loader/dist/cjs.js
* ./node_modules/ts-loader/index.js
* ./node_modules/eslint-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| }
| isAdmin() {
> return this.account ? .authorities.includes('ROLE_ADMIN') : ;
| }
| };
ℹ 「wdm」: Failed to compile.
As a workaround, if I just hard-code the return value to 'true' in the isAdmin() method it works and compiles. How come just checking to see if the array contains something causes the webpack to freak out?
Optional chaining was introduced in Typescript 3.7, current JHipster 6.7.1 uses Typescript 3.4.5 so it's not very surprising that your expression is not understood and translated as ternary operator.
Try upgrading typescript version in package.json and npm install to see if it solves it.

Apollo - React (Typescript) Invariant Error when building production build

I am creating a new react app with gatsby, typescript, and apollo (for graphql queries).
When testing in dev, the app compiles and runs with no errors thrown.
When I transpile the build, using 'gatsby build', it fails with an error.
I don't understand why or where this is being triggered. It seems to be something to do with the way webpack is checking as it's building, but I don't know how to pinpoint the issue and there doesn't seem to be any material out there with a clear answer for me.
It seems to be caused by the httplink module. The code that triggers the error when present in any .tsx file is:
import { HttpLink } from 'apollo-link-http'
const link = new HttpLink({
uri: 'http://localhost:3001/graphql'
})
The error shown is the following:
error Building static HTML failed
See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html
10 | function InvariantError(message) {
11 | if (message === void 0) { message = genericMessage; }
> 12 | var _this = _super.call(this, typeof message === "number"
| ^
13 | ? genericMessage + ": " + message + " (see https://github.com/apollographql/invariant-packages)"
14 | : message) || this;
15 | _this.framesToPop = 1;
WebpackError: Invariant Violation: Invariant Violation: 1 (see https://github.com/apollographql/invariant-packages)
- invariant.esm.js:12 new InvariantError
[lib]/[apollo-link-http-common]/[ts-invariant]/lib/invariant.esm.js:12:1
- bundle.esm.js:64 checkFetcher
[lib]/[apollo-link-http-common]/lib/bundle.esm.js:64:52
- bundle.esm.js:8 createHttpLink
[lib]/[apollo-link-http]/lib/bundle.esm.js:8:17
- bundle.esm.js:139 new HttpLink
[lib]/[apollo-link-http]/lib/bundle.esm.js:139:1
- Strategy.tsx:6 Module../src/components/Strategy.tsx
lib/src/components/Strategy.tsx:6:14
- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1
- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1
- sync-requires.js:10 Object../.cache/sync-requires.js
lib/.cache/sync-requires.js:10:56
- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1
- static-entry.js:9 Module../.cache/static-entry.js
lib/.cache/static-entry.js:9:22
- bootstrap:19 __webpack_require__
lib/webpack/bootstrap:19:1
- bootstrap:83
lib/webpack/bootstrap:83:1
- universalModuleDefinition:3 webpackUniversalModuleDefinition
lib/webpack/universalModuleDefinition:3:1
- universalModuleDefinition:10 Object.<anonymous>
lib/webpack/universalModuleDefinition:10:2"
Is this typescript issue, gatsby issue, apollo issue, or a webpack issue? Or a combination?
Thank you for any help you can give! I'm struggling with my understanding of all the pieces here.
I understand that Invariant Violations are about an issue with the wrong types being referenced. Because this occurs in the module, I'm not sure if I'm doing something wrong, or if it's an issue inside the imported library. Maybe it's an issue that I'm forcing typescript checks on a basic javascript based library. I still didn't quite come to a conclusion on this.
I tried adding the following config to gatsby-node.js to ignore the module checks (as suggested here: https://gatsby.dev/debug-html), with no successful build, though the error did change, as it could not see the module.
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /apollo-link-http/,
use: loaders.null(),
},
],
},
})
}
}
To recap, this is the code designed to create the client object to enable queries to the graphql endpoint. When running 'gatsby build' the in variant error occurs (see above).
import * as React from 'react'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { HttpLink } from 'apollo-link-http'
const cache = new InMemoryCache()
const link = new HttpLink({
uri: 'http://localhost:3001/graphql'
})
const client = new ApolloClient({
cache,
link
})
I'm a newbie at this. After hours of looking I finally tracked down the error in the file. On closer inspection, when the environment is production (process.env.NODE_ENV === "production"), then the error is not detailed. So I looked at what the error would be if the environment was something else, and changed the file to output this to the console. What I got back was:
fetch is not found globally and no fetcher passed, to fix pass a fetch for
your environment like https://www.npmjs.com/package/node-fetch.
For example:
import fetch from 'node-fetch';
import { createHttpLink } from 'apollo-link-http';
const link = createHttpLink({ uri: '/graphql', fetch: fetch });
I added fetch to my code, and it built a production version with no errors.
I don't understand why this error was not thrown with the dev environment, but I guess it's something to do with the lazy loading.
Problem fixed.

react-native-navigation 1.1.45 and RN 0.43 compatibility

I am not able to setting up react-native-navigation for android version. My IOS app is working fine with same version of RNN and RN.
Help me configure for android.
Here is few important file from my app,
MainActivity.java
package com.MY_APP_NAME;
import com.facebook.react.ReactActivity;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.bridge.NavigationReactPackage;
public class MainActivity extends ReactActivity {
#Override
protected String getMainComponentName() {
return "ttapp";
}
}
MainApplication.java
package com.MY_APP_NAME;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.oblador.vectoricons.VectorIconsPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage()
);
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
/App/build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId 'com.MY_APP_NAME'
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
productFlavors {
}
}
dependencies {
compile project(':react-native-splash-screen')
compile project(':react-native-navigation')
compile project(':react-native-vector-icons')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.0.3'
compile 'com.facebook.react:react-native:+'
// From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
Everything is working fine. App is also successfully builded. But react-native-navigation is not working.
Are you getting a white screen on the android device? It also happen to me (only while you have debugger enabled), but if you switch task you're good to go. Try to check this issue on the repo, maybe you could find your answers.
BTW as stated by Pritish, in the READ.ME the minimum version of RN supported is 0.48, for v2 you need version 0.51

how to configure a FileEntityStoreService

I'm trying to use a File EntityStore and I'm having an exception at activation because of slices being zero.
I assume it's an issue with configuration but I expected the default value to be 1.
I narrowed down to this assembly:
import org.apache.polygene.api.common.Visibility;
import org.apache.polygene.api.structure.Application;
import org.apache.polygene.bootstrap.Energy4Java;
import org.apache.polygene.entitystore.file.assembly.FileEntityStoreAssembler;
import org.apache.polygene.index.rdf.assembly.RdfNativeSesameStoreAssembler;
import org.apache.polygene.library.fileconfig.FileConfigurationAssembler;
public class FileStoreException {
public static void main(String[] args) throws Exception {
Energy4Java polygene = new Energy4Java();
Application application = polygene.newApplication(factory -> factory.newApplicationAssembly(
module -> {
new FileConfigurationAssembler()
.visibleIn(Visibility.application)
.assemble(module);
new FileEntityStoreAssembler()
.withConfig(module, Visibility.application)
.assemble(module);
new RdfNativeSesameStoreAssembler()
.withConfig(module, Visibility.application)
.assemble(module);
module.defaultServices();
})
);
application.activate();
}
}
The end of the stacktrace:
Caused by: java.lang.ArithmeticException: / by zero
at method "get" of FileEntityStoreService:FileEntityStoreService in module [Module 1] of layer [Layer 1].(:0)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.getDataFile(FileEntityStoreMixin.java:277)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.getDataFile(FileEntityStoreMixin.java:328)
at org.apache.polygene.entitystore.file.FileEntityStoreMixin.get(FileEntityStoreMixin.java:138)
at org.apache.polygene.spi.entitystore.helpers.JSONMapEntityStoreMixin.entityStateOf(JSONMapEntityStoreMixin.java:193)
... 14 more
I'm using version 3.0.0 and I'm on linux.
Adding FileConfigurationAssembler gave me the false impression that my config was done.
I struggled to find a working example of an assembly using a FileEntityStoreAssembler so here's one:
Application application = polygene.newApplication(factory -> factory.newApplicationAssembly(
module -> {
ModuleAssembly config = module.layer().module("Config");
config.defaultServices();
new MemoryEntityStoreAssembler().assemble(config);
config.entities(FileEntityStoreConfiguration.class);
new FileEntityStoreAssembler()
.withConfig(config, Visibility.application)
.assemble(module);
new RdfNativeSesameStoreAssembler()
.withConfig(config, Visibility.application)
.assemble(module);
module.defaultServices();
})
);
And to configure it:
config.forMixin(FileEntityStoreConfiguration.class)
.declareDefaults()
.directory().set("/home/user/appdata/");

Resources