ionic build androidエラー

✗ ionic build android

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Running command: /Users/HOkaniwa/ionic_projects/my-reddit/hooks/after_prepare/010_add_platform_class.js /Users/HOkaniwa/ionic_projects/my-reddit
add to body class: platform-android
Error: Please install Android target: "android-23".

Hint: Open the SDK manager by running: /Users/HOkaniwa/Library/Android/sdk/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)

 

 

qiita.com

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys.

 

 

もともと:

<a class = "item item-thumbnail-left" ng-repeat="story in stories track by story.id" href="{{story.url}}" target="_blank">

 

エラー:

ionic.bundle.js

Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys.

 

解決:

<a class = "item item-thumbnail-left" ng-repeat="story in stories track by $index" href="{{story.url}}" target="_blank">

 

参考

qiita.com

AngularJSでモジュールのdependencyを追加できないエラー

app.js, index.htmlをチェックした。

index.htmlでのscript読み込みでの問題が発見された。

 

元:

<script src="components/moment/moment.js"></script>
<script src="components/angular-moment/angular-moment.js"></script>

<script src="lib/ionic/js/ionic.bundle.js"></script>

<script src="cordova.js"></script>
<script src="js/app.js"></script>

 

問題:

1:パスが違う libから読むべき

2:読み込む順番が違う ionic.bundle.jsの後に読むべき

参考:

javascript - How to add more than one dependency module in AngularJS - Stack Overflow

 

解決策:

<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- angular-moment https://github.com/urish/angular-moment -->
<script src="lib/moment/moment.js"></script>
<script src="lib/angular-moment/angular-moment.js"></script>

<script src="cordova.js"></script>
<script src="js/app.js"></script>

Ionicインストール 環境構築まとめ

インストール時

1:XCodeをインストールする

2:npmをインストールする

3:ionicをインストールする

ーーーーーーーーーーーーーーーー

➜  ~ npm install -g ionic

npm ERR! tar.unpack untar error  などなど

解決策:

1:推奨: パスを設定

➜ ~ npm config set prefix ~/npm
➜ ~ export PATH="$PATH:$HOME/npm/bin"

2:強制的に実行

sudo npm install -g ionic

参考 Stackoverflow etc.

ーーーーーーーーーーーーーーーーーーー

4:ionicで新しいプロジェクトを始める

ーーーーーーーーーーーーーーーーーーー

 

➜ ~ ionic start myproject
******************************************************
Dependency warning - for the CLI to run correctly,
it is highly recommended to install/upgrade the following:

Please install your Cordova CLI to version >=4.2.0 `npm install -g cordova`
Install ios-sim to deploy iOS applications. `npm install -g ios-sim` (may require sudo)
Install ios-deploy to deploy iOS applications to devices. `npm install -g ios-deploy` (may require sudo)

******************************************************
Creating Ionic app in folder /Users/home/myproject based on tabs project
Downloading: https://github.com/driftyco/ionic-app-base/archive/master.zip
[=============================] 100% 0.0s
Downloading: https://github.com/driftyco/ionic-starter-tabs/archive/master.zip
[=============================] 100% 0.0s
Updated the hooks directory to have execute permissions
Update Config.xml
Initializing cordova project
Adding in iOS application by default
Added ios platform

♬ ♫ ♬ ♫ Your Ionic app is ready to go! ♬ ♫ ♬ ♫

Make sure to cd into your new app directory:
cd myproject

To run your app in the browser (great for initial development):
ionic serve

To run on iOS:
ionic run ios

To run on Android:
ionic run android

To test your app on a device easily, try Ionic View:
http://view.ionic.io

Create an ionic.io account to send Push Notifications and use the Ionic View app?

 


+---------------------------------------------------------+
+ Extra! Extra! Fresh Ionic updates for June 2016
+
+ Ionic 2 Beta is out! Try the next generation of Ionic
+ http://ionicframework.com/docs/v2/getting-started/installation/
+
+ Test and share your Ionic apps easily with Ionic View
+ http://view.ionic.io
+
+ Building enterprise apps? Ionic Enterprise Framework comes with the support and features you need
+ http://ionic.io/enterprise
+
+---------------------------------------------------------+

ーーーーーーーーーーーーーーーーーーー

5:念のためインストールするべきと言われたものをインストールする

ーーーーーーーーーーーーーーーーーーー

4の注意書きより:

 

Install your Cordova CLI to version >=4.2.0 `npm install -g cordova`
Install ios-sim to deploy iOS applications. `npm install -g ios-sim` (may require sudo)
Install ios-deploy to deploy iOS applications to devices. `npm install -g ios-deploy` (may require sudo)

 

➜ ~ npm install -g cordova
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

~ npm install -g ios-sim

➜ ~ npm install -g ios-deploy
> ios-deploy@1.8.6 preinstall /Users/HOkaniwa/npm/lib/node_modules/ios-deploy
> ./src/scripts/check_reqs.js && xcodebuild

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!! WARNING: You are on OS X 10.11 El Capitan, you may need to add the
!!!! WARNING: `--unsafe-perm=true` flag when running `npm install`
!!!! WARNING: or else it will fail.
!!!! WARNING: link:
!!!! WARNING: https://github.com/phonegap/ios-deploy#os-x-1011-el-capitan
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=== BUILD TARGET ios-deploy-lib OF PROJECT ios-deploy WITH THE DEFAULT CONFIGURATION (Release) ===

 

いろいろ exportしているログが表示されたのち

 

** BUILD SUCCEEDED **

/Users/**home**/npm/bin/ios-deploy -> /Users/**home**/npm/lib/node_modules/ios-deploy/build/Release/ios-deploy
ios-deploy@1.8.6 /Users/**home**/npm/lib/node_modules/ios-deploy

 

ーーーーーーーーーーーーーーーーーーー

 6:プロジェクト開始からサーバでの提示、エミュレータの起動

$ ionic start myApp blank
$
cd myApp

$ ionic serve
$ ionic platform add ios $ ionic build ios $ ionic emulate ios

このままにしてても大丈夫だったエラー?:

➜ firstApp ionic emulate ios

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using this version of Cordova with older version of cordova-ios is being deprecated. Consider upgrading to cordova-ios@4.0.0 or newer.
cp: no such file or directory: /Users/*home*/ionic_projects/firstApp/resources/ios/icon/icon-40@3x.png

 

ーーーーーーーーーーーーーーーーーーー

7:bower, gulpをインストール

インストールするコマンドは通ったが、パスについてのログが出る。

そして、コマンドが見つからないというエラー:

➜ npm install -g bower
/Users/**home**/npm/bin/bower -> /Users/**home**/npm/lib/node_modules/bower/bin/bower
bower@1.7.9 /Users/**home**/npm/lib/node_modules/bower
➜ bower
zsh: command not found: bower

 

解決策:

➜ export PATH=/Users/**home**/npm/bin:$PATH
➜ export PATH=/Users/**home**/npm/lib/node_modules/bower/bin:$PATH 

 

ーーーーーーーー

既存のプロジェクトで使えなくなった時にすること

npm install -g ionicnpm install -g ionic/Users/name/ionic_projects/bin/ionic -> /Users/name/ionic_projects/lib/node_modules/ionic/bin/ionic

 

export PATH="$PATH:$HOME/ionic_projects/lib/node_modules/ionic/bin" 

 

 

ionicframework.com

 

Ionic Framework Tutorial

 

 

 

 

 

 

Java メモ

ーーーーーー

method obsolete、primitive intなどのエラーが

int to stringをしたあとlengthを求めるときにでる

問題:

int n = stdIn.nextInt();

        Integer.toString(n);

解決:

int n = stdIn.nextInt();

        String n_string = Integer.toString(n);

代入して渡す。

 

最終形態;

import java.util.Scanner;

public class text4_8 {

public static void main(String args) {

Scanner stdIn = new Scanner(System.in);

System.out.print("整数値の桁数を出力します。値を入力してください。:");

int n = stdIn.nextInt();

// int to string Integer.toString(i)

String n_string = Integer.toString(n);

// get length and print

int len = n_string.length();

System.out.print(len);

}

 

}

 

ーーーーーーーー

 

乱数の値のmin maxを決める

int no = rand.nextInt(100-9); // 当てるべき数:10〜99の乱数として生成

 

import java.util.Random;

import java.util.Scanner;

public class text4_2 {

public static void main(String args) {

Random rand = new Random();

Scanner stdIn = new Scanner(System.in);

 

int no = rand.nextInt(100-9); // 当てるべき数:10〜99の乱数として生成

System.out.println("数当てゲーム開始!!");

System.out.println("10〜99の数を当ててください。");

int x; // プレーヤが入力した数

do {

System.out.print("いくつかな:");

x = stdIn.nextInt();

if (x > no)

System.out.println("もっと小さな数だよ。");

else if (x < no)

System.out.println("もっと大きな数だよ。");

} while (x != no);

 

System.out.println("正解です。");

}

 

}

 

 

 

ーーーーーーーー

改行

System.out.println()で改行できる

をうてる。

 

import java.util.Scanner;

public class text4_20 {

public static void main(String args) {

Scanner stdIn = new Scanner(System.in);

System.out.println("n段の正方形を表示します。数を入力してください。:");

int n = stdIn.nextInt();

// for文を二つ重ねる

for (int i = 0; i < n; i++){

for (int j = 0; j < n; j++){

System.out.print("*");

}

System.out.println();

}

}

 

}

ーーーーーーーーーー

 

割られる数の形、例えばint 型に入ってからdoubleになるので   2.0とかになっちゃう

2.333だとしても。

解決:

 

 

import java.util.Scanner;

public class text4_26 {

public static void main(String args) {

Scanner stdIn = new Scanner(System.in);

 

System.out.println("整数を加算します。");

System.out.print("何個加算しますか:");

int n = stdIn.nextInt(); // 加算する個数

 

double sum = 0; // 合計値

int num_calc = 0;

for (int i = 0; i < n; i++) {

System.out.print("整数:");

int t = stdIn.nextInt();

if (t < 0) {

System.out.println("負の数は加算しません。");

continue;

}

sum += t;

num_calc = i+1;å

}

System.out.println("合計は" + sum + "です。");

double avg = sum/num_calc;

System.out.println("平均は" + avg + "です。");

}

 

}

 

 

 

 

 

 

Java クラス 入力した変数が代入されない

 

エラー:

入力した変数が代入されない

 

原因:入れる値の名前とそれを代入する先の変数が同じ名前。

Bank(int num, int pass, int money, String name){
number = num;
password = pass;
money = money;
name = name;
}

 

 

解決(全コード):

class Bank {
private int number;
private int password;
private int money;
private String name;

Bank(int num, int pass, int mon, String nm){
number = num;
password = pass;
money = mon;
name = nm;
}

public void report(){
System.out.println("-- 口座開設報告 --");
System.out.println(this.name+"さんの口座を開設できました。");
System.out.println("口座番号は"+this.number+"です。");
System.out.println("パスワードは"+ this.password+"です。");
System.out.println("初期入金は"+this.money+"円です。");
}
}

public class Question120 {
public static void main(String[] args) {
int num = Integer.parseInt(args[0]);
int pass = Integer.parseInt(args[1]);
int money = Integer.parseInt(args[2]);
String name = args[3];

Bank person = new Bank(num, pass, money, name);
person.report();
}
}